/* YYSI Start — styles */

* { box-sizing: border-box; }

:root {
  --bg: #eef1f6;
  --top: rgba(255, 255, 255, .78);
  --card: #ffffff;
  --border: #dce1ea;
  --text: #1d2433;
  --muted: #6b7688;
  --accent: #3e63f4;
  --accent-soft: rgba(62, 99, 244, .12);
  --accent-border: rgba(62, 99, 244, .5);
  --danger: #e5484d;
  --hover: #f0f3fa;
  --shadow: 0 1px 2px rgba(18, 28, 45, .06), 0 6px 18px rgba(18, 28, 45, .07);
}

[data-theme="dark"] {
  --bg: #0d1017;
  --top: rgba(13, 16, 23, .8);
  --card: #161b24;
  --border: #293040;
  --text: #e8ebf3;
  --muted: #9099ad;
  --accent: #7288ff;
  --accent-soft: rgba(114, 136, 255, .14);
  --accent-border: rgba(114, 136, 255, .5);
  --danger: #f05a5f;
  --hover: #1d2431;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 22px rgba(0, 0, 0, .35);
}

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

.hidden { display: none !important; }

/* ---------- top bar ---------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--top);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

#clockbox { flex: none; min-width: 118px; }
#clock-time { font-size: 20px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
#clock-date { font-size: 11.5px; color: var(--muted); }

#searchbox {
  flex: 1;
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 14px 2px 6px;
  box-shadow: var(--shadow);
}

#engine {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  padding: 6px 4px 6px 8px;
  cursor: pointer;
  outline: none;
  flex: none;
}

#search {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  padding: 8px 4px;
  outline: none;
}
#search::placeholder { color: var(--muted); }
#search::-webkit-search-cancel-button { -webkit-appearance: none; }

#search-count {
  flex: none;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 8px;
}

#topbar-actions { flex: none; display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.menu-wrap { position: relative; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  z-index: 60;
}
.menu button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.menu button:hover { background: var(--hover); }

/* ---------- board & groups ---------- */

#main { flex: 1; width: 100%; max-width: 1560px; margin: 0 auto; padding: 20px 24px 32px; }

#groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 10px;
  user-select: none;
  -webkit-user-select: none;
}

.grip {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: -2px;
  cursor: grab;
  padding: 0 2px;
}
.grip:active { cursor: grabbing; }

.gname {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}

.gcount { flex: none; font-size: 11.5px; color: var(--muted); background: var(--hover); border-radius: 999px; padding: 1px 8px; }

.head-actions { flex: none; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.card:hover .head-actions { opacity: 1; }

.hbtn {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.hbtn:hover { background: var(--hover); color: var(--accent); }
.hbtn.g-del:hover { color: var(--danger); }

/* ---------- tiles ---------- */

.tiles {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
  flex: 1;
}

.tile {
  position: relative;
  min-width: 0;
  min-height: 84px;
  border-radius: 10px;
  user-select: none;
  -webkit-user-select: none;
}

.tile-main {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 6px 8px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}
.tile:hover .tile-main { background: var(--hover); }

.fav {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  overflow: hidden;
  flex: none;
}
.fav img { width: 26px; height: 26px; }
.fav-fallback { color: #fff; font-size: 15px; font-weight: 600; }

.tlabel {
  max-width: 100%;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.tile-actions {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 2;
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity .15s;
}
.tile:hover .tile-actions { opacity: 1; }

.tile-actions .hbtn { width: 20px; height: 20px; font-size: 11px; background: var(--card); border: 1px solid var(--border); }
.tile-actions .hbtn:hover { background: var(--hover); }

.add-tile {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  min-height: 84px;
  padding: 8px;
}
.add-tile:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.add-plus { font-size: 18px; line-height: 1; }
.add-label { font-size: 11.5px; }

/* ---------- special cards ---------- */

.new-group {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  min-height: 120px;
  display: flex;
  flex-direction: column;
}
.new-group:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ng-plus { font-size: 22px; line-height: 1; }
.new-group span:last-child { font-size: 13px; }

.empty-card, .no-match {
  grid-column: 1 / -1;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-card h3, .no-match h3 { color: var(--text); font-size: 16px; }

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 9px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost:hover { background: var(--hover); }

/* ---------- drag feedback ---------- */

.dragging { opacity: .35; }

.tile.ins-before::before, .tile.ins-after::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
}
.tile.ins-before::before { left: -6px; }
.tile.ins-after::after { right: -6px; }

.tiles.ins-end::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  right: -6px;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
}

.card.ins-before::before, .card.ins-after::after {
  content: '';
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
}
.card.ins-before::before { left: -11px; }
.card.ins-after::after { right: -11px; }

.card.hot { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }

body.drag-external .card:not(.new-group) { border-style: dashed; border-color: var(--accent-border); }
#main.drop-target { outline: 2px dashed var(--accent-border); outline-offset: -6px; border-radius: 14px; }

#drag-hint {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  padding: 7px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

/* ---------- footer ---------- */

#hints {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
  padding: 4px 20px 18px;
}
#hints i { font-style: normal; margin: 0 7px; opacity: .5; }

/* ---------- modal ---------- */

#modal-root:empty { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(9, 12, 20, .45);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: min(460px, 100%);
  padding: 20px;
}

.modal h3 { font-size: 16px; margin-bottom: 14px; }

.field { display: block; margin-bottom: 12px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13.5px;
  outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.chooser-url {
  font-size: 12.5px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 11px;
  margin-bottom: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip-new { border-style: dashed; }
.chip-n { font-size: 11px; color: var(--muted); background: var(--hover); border-radius: 999px; padding: 1px 7px; }

.help-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 9px; font-size: 13px; line-height: 1.5; }
.help-list b { color: var(--accent); }

/* ---------- toast ---------- */

#toast-root:empty { display: none; }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  background: #1d2433;
  color: #f2f4f8;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 40px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-theme="dark"] .toast { background: #2a3242; }

.toast-act {
  border: 0;
  background: transparent;
  color: #9db1ff;
  font-size: 13px;
  cursor: pointer;
  flex: none;
}
.toast-act:hover { text-decoration: underline; }

/* ---------- focus & touch ---------- */

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (hover: none) {
  .head-actions, .tile-actions { opacity: .65; }
}

/* ---------- account & auth ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.account-pill {
  height: 34px;
  max-width: 200px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  padding: 0 14px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-pill:hover { border-color: var(--accent); color: var(--accent); }
.account-pill.signed-in { color: var(--accent); border-color: var(--accent-border); background: var(--accent-soft); }

.menu-head {
  padding: 8px 10px 6px;
  font-size: 12px;
  color: var(--muted);
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.auth-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 9px;
  padding: 8px;
  cursor: pointer;
  font-size: 13px;
}
.auth-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.auth-error { display: none; color: var(--danger); font-size: 12.5px; margin: 10px 0 0; }
.auth-note { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.5; }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  #clockbox { display: none; }
  #topbar { padding: 8px 12px; }
  #board { padding: 14px 12px 24px; }
  #groups { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
}
