@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Noto+Sans+SC:wght@400;500;700;900&display=swap");

:root {
  --bg-top: #eef4ff;
  --bg-bottom: #dfe9f7;
  --panel: #f8fbffcc;
  --panel-solid: #f8fbff;
  --line: #c9d6eb;
  --text-main: #122035;
  --text-secondary: #3d4f66;
  --btn-main: #1f5fff;
  --btn-main-ink: #f3f7ff;
  --btn-alt: #d8e2f6;
  --counter-bg: #dce8ff;
  --card-bg: #ffffff;
  --tag-bg: #cde0ff;
  --shape-a: #afcbff;
  --shape-b: #8cb6ff;
}

body[data-theme="focus-floor"] {
  --bg-top: #ecf2ff;
  --bg-bottom: #dce8fb;
  --panel: #f7faffcc;
  --panel-solid: #f7faff;
  --line: #c7d6f0;
  --text-main: #11213d;
  --text-secondary: #3f5372;
  --btn-main: #2465ff;
  --btn-main-ink: #edf3ff;
  --btn-alt: #d7e3fb;
  --counter-bg: #d6e4ff;
  --card-bg: #fcfdff;
  --tag-bg: #cedfff;
  --shape-a: #a9c8ff;
  --shape-b: #8fb4ff;
}

body[data-theme="meeting-room"] {
  --bg-top: #f3f5f0;
  --bg-bottom: #e2e8dc;
  --panel: #fbfdf8d1;
  --panel-solid: #fbfdf8;
  --line: #ccd8c2;
  --text-main: #1f2d18;
  --text-secondary: #4b5d44;
  --btn-main: #2e7b4d;
  --btn-main-ink: #edf7f0;
  --btn-alt: #d8e7d7;
  --counter-bg: #d8e9d8;
  --card-bg: #fefffc;
  --tag-bg: #cae7cd;
  --shape-a: #b6ddc1;
  --shape-b: #9fcdac;
}

body[data-theme="command-center"] {
  --bg-top: #202833;
  --bg-bottom: #151c27;
  --panel: #1f2938d8;
  --panel-solid: #1f2938;
  --line: #344359;
  --text-main: #edf2fd;
  --text-secondary: #b8c6dd;
  --btn-main: #ff7a3d;
  --btn-main-ink: #281408;
  --btn-alt: #354661;
  --counter-bg: #3c4d67;
  --card-bg: #243145;
  --tag-bg: #3f5471;
  --shape-a: #2f425b;
  --shape-b: #37536f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--text-main);
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  position: relative;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  filter: blur(2px);
  opacity: 0.42;
}

.shape-a {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--shape-a) 75%, #ffffff 25%), var(--shape-a) 72%);
  top: -120px;
  left: -90px;
}

.shape-b {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle at 70% 30%, color-mix(in srgb, var(--shape-b) 75%, #ffffff 25%), var(--shape-b) 72%);
  right: -70px;
  bottom: -90px;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1160px, 92vw);
  margin: 24px auto 48px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.hero h1 {
  margin: 8px 0;
  font-size: clamp(1.9rem, 4.8vw, 3.3rem);
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
  letter-spacing: 0.01em;
}

.badge {
  display: inline-block;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--tag-bg);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.subtitle {
  color: var(--text-secondary);
  margin-top: 6px;
}

.theme-switch {
  min-width: 210px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.theme-switch label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-weight: 600;
}

body.app-mode .hero {
  display: none;
}

body.app-mode .shell {
  width: 100vw;
  margin: 0;
}

/* ── Download banner ─────────────────────────────────────────────────────── */
.download-banner {
  margin-top: 16px;
  padding: 12px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  backdrop-filter: blur(6px);
}

.download-banner.hidden {
  display: none;
}

.download-banner-label {
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.93rem;
  white-space: nowrap;
}

.download-banner-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 18px;
  border-radius: 9px;
  background: var(--btn-alt);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  transition: background 0.15s, transform 0.15s;
  border: 1px solid var(--line);
}

.download-btn:hover {
  background: var(--btn-main);
  color: var(--btn-main-ink);
  border-color: var(--btn-main);
  transform: translateY(-1px);
}

.download-btn[hidden] {
  display: none;
}

/* ── Admin upload styles ──────────────────────────────────────────────────── */

.panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(6px);
  box-shadow: 0 14px 40px #0e1d3a24;
}

#appPanel {
  margin-top: 12px;
  padding: 0;
  border: none;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
}

.grid {
  display: grid;
  gap: 14px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.form-card h3,
.form-card h4 {
  margin-top: 2px;
}

.hint {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

label {
  display: block;
  margin: 8px 0 6px;
  font-weight: 600;
  color: var(--text-secondary);
}

input,
select,
textarea,
button {
  width: 100%;
  border-radius: 10px;
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 10px;
  color: #122035;
}

body[data-theme="command-center"] input,
body[data-theme="command-center"] select,
body[data-theme="command-center"] textarea {
  background: #182232;
  color: #edf2fd;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.btn {
  border: 0;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--btn-alt);
  color: var(--text-main);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px #12203b2c;
}

.btn.primary {
  background: var(--btn-main);
  color: var(--btn-main-ink);
}

.btn.ghost {
  background: var(--btn-alt);
  width: auto;
}

.inline-btn {
  width: auto;
  margin-top: 0;
  padding: 8px 12px;
}

.captcha-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.captcha-question {
  display: inline-block;
  background: color-mix(in srgb, var(--counter-bg) 70%, #ffffff 30%);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.top-banner {
  position: fixed;
  top: 10px;
  left: 14px;
  right: 14px;
  z-index: 12;
  margin-bottom: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 82%, transparent 18%);
  backdrop-filter: blur(10px);
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
}

.banner-main h2 {
  margin: 0;
}

.banner-main .subtitle {
  margin: 4px 0 0;
}

.banner-counters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-dot-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-solid) 86%, transparent 14%);
}

.theme-dot {
  width: 14px;
  height: 14px;
  min-width: 14px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--line) 70%, #ffffff 30%);
  margin: 0;
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px #ffffff8a;
}

.theme-dot[data-theme="focus-floor"] {
  background: linear-gradient(135deg, #8fb4ff, #2465ff);
}

.theme-dot[data-theme="meeting-room"] {
  background: linear-gradient(135deg, #9fcdac, #2e7b4d);
}

.theme-dot[data-theme="command-center"] {
  background: linear-gradient(135deg, #37536f, #ff7a3d);
}

.theme-dot.active {
  transform: scale(1.15);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--btn-main) 28%, transparent 72%);
}

.counter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 6px 10px;
  font-size: 0.84rem;
  background: color-mix(in srgb, var(--counter-bg) 72%, transparent 28%);
}

.counter-chip strong {
  font-size: 0.95rem;
}

.banner-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.mini-btn {
  width: auto;
  margin: 0;
  border: 1px solid color-mix(in srgb, var(--line) 75%, #ffffff 25%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--btn-alt) 78%, transparent 22%);
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 700;
  padding: 6px 12px;
  cursor: pointer;
}

.mini-btn.danger {
  background: #f7d7d7cc;
  border-color: #e9b0b0;
}

body[data-theme="command-center"] .mini-btn.danger {
  background: #6a323280;
  border-color: #915252;
}

.sticky-wall {
  position: fixed;
  inset: 0;
  top: 74px;
  bottom: 56px;
  border-radius: 0;
  background:
    radial-gradient(circle at 12% 16%, color-mix(in srgb, var(--shape-a) 26%, transparent 74%), transparent 56%),
    radial-gradient(circle at 88% 80%, color-mix(in srgb, var(--shape-b) 23%, transparent 77%), transparent 60%),
    linear-gradient(160deg, color-mix(in srgb, var(--panel) 58%, transparent 42%), color-mix(in srgb, transparent 70%, var(--panel-solid) 30%));
  overflow: hidden;
  border: 1px dashed color-mix(in srgb, var(--line) 68%, transparent 32%);
}

.note {
  position: absolute;
  width: 186px;
  min-height: 158px;
  border-radius: 8px;
  border: 1px solid #ddc98f;
  padding: 10px;
  background: var(--note-color, #fff1a8);
  box-shadow: 0 8px 16px #45301430;
  transform: rotate(var(--note-rotate, -1deg));
  cursor: grab;
  touch-action: none;
  user-select: none;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 6px;
}

.note.dragging {
  cursor: grabbing;
  box-shadow: 0 14px 28px #2d211848;
}

.note-top {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
}

.note-done-btn {
  width: auto;
  border: 1px solid color-mix(in srgb, var(--btn-main) 38%, #ffffff 62%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--btn-main) 88%, #ffffff 12%);
  color: var(--btn-main-ink);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  padding: 6px 12px;
  cursor: pointer;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--btn-main) 18%, transparent 82%);
}

.note-done-btn:disabled {
  cursor: default;
  opacity: 0.68;
  box-shadow: none;
}

.note-tag {
  border-radius: 999px;
  border: 1px solid #a7b4c77a;
  background: #ffffff99;
  padding: 1px 7px;
  font-size: 0.72rem;
  color: #3a4457;
}

.note-source {
  margin: 4px 0 2px;
  font-size: 0.86rem;
  color: #453d31;
}

.note-source-text {
  display: inline-block;
  max-width: 102px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.note-content {
  margin: 6px 0;
  line-height: 1.4;
  min-height: 54px;
  word-break: break-word;
  color: #2f2a22;
  user-select: text;
}

.note-editor {
  width: 100%;
  min-height: 66px;
  margin: 6px 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  resize: none;
  box-shadow: none;
  outline: none;
}

.note-editor[readonly] {
  cursor: default;
}

.note .meta {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: #554b3d;
}

.note-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
}

.note-footer-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.note-actions {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.history-wrap {
  margin-top: 8px;
}

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}

.history-empty {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 4px 2px;
}

/* ── Card item ── */
.history-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: color-mix(in srgb, var(--card-bg) 96%, #ffffff 4%);
}

.history-color-bar {
  width: 5px;
  min-height: 44px;
  border-radius: 3px;
  flex-shrink: 0;
  align-self: stretch;
}

.history-body {
  flex: 1;
  min-width: 0;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.history-type-badge {
  display: inline-block;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.history-type-badge.badge-mine {
  background: #dbeafe;
  color: #1e40af;
}

.history-type-badge.badge-received {
  background: #dcfce7;
  color: #166534;
}

.history-type-badge.badge-sent {
  background: #fef3c7;
  color: #92400e;
}

.history-from {
  font-size: 0.82rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-time-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-left: auto;
  flex-shrink: 0;
}

.history-content {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-main);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.history-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
  justify-content: center;
  padding-top: 2px;
}

.history-delete-btn {
  width: auto;
  margin: 0;
  border: 1px solid #d7a2a2;
  border-radius: 999px;
  background: #fff5f5;
  color: #b42318;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

body[data-theme="command-center"] .history-delete-btn {
  background: #4b2730;
  border-color: #7a4752;
  color: #ffd7d7;
}

.history-status-btn {
  width: auto;
  border: 1px solid;
  border-radius: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.history-status-btn.history-status-open {
  background: #ecfdf5;
  color: #059669;
  border-color: #6ee7b7;
}

.history-status-btn.history-status-done {
  background: #f3f4f6;
  color: #9ca3af;
  border-color: #e5e7eb;
  text-decoration: line-through;
}

.history-status-dot {
  font-size: 0.75rem;
  border-radius: 5px;
  padding: 3px 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.history-status-dot.history-status-open {
  background: #ecfdf5;
  color: #059669;
  border-color: #6ee7b7;
}

.history-status-dot.history-status-done {
  background: #f3f4f6;
  color: #9ca3af;
  border-color: #e5e7eb;
  text-decoration: line-through;
}

.history-show-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.history-show-toggle.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.history-show-checkbox {
  width: 13px;
  height: 13px;
  margin: 0;
  cursor: pointer;
}

.history-status-open {
  background: #ffeeb5;
  color: #7a5c00;
}

.history-status-done {
  background: #d9f3df;
  color: #1f6c33;
}

.history-inline-tip {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.empty {
  margin: 2px 0;
  color: var(--text-secondary);
}

.wall-empty {
  margin: 0;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--panel-solid) 78%, transparent 22%);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: center;
}

.status {
  min-height: 1.2em;
  margin: 14px 2px;
  color: var(--text-secondary);
}

body.app-mode .status {
  position: fixed;
  z-index: 16;
  right: 18px;
  bottom: 12px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel-solid) 86%, transparent 14%);
  border: 1px solid var(--line);
}

.site-footer {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

body.app-mode .site-footer {
  position: fixed;
  z-index: 15;
  left: 14px;
  bottom: 12px;
  margin-top: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel-solid) 84%, transparent 16%);
}

.site-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px dashed var(--line);
}

.site-footer a:hover {
  color: var(--text-main);
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #0d1a2a75;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: min(1080px, 95vw);
  max-height: min(86vh, 920px);
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-solid);
  box-shadow: 0 24px 56px #0f1e3540;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-card.narrow {
  width: min(420px, 95vw);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.modal-head h3 {
  margin: 0;
}

.modal-close {
  width: auto;
  min-width: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--btn-alt);
  color: var(--text-main);
  cursor: pointer;
  padding: 6px 10px;
  font-weight: 700;
}

.logout-tip {
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions .btn {
  width: auto;
}

.hidden {
  display: none;
}

.reveal {
  animation: riseIn 0.55s ease both;
}

.delay-1 {
  animation-delay: 0.08s;
}

.delay-2 {
  animation-delay: 0.15s;
}

.delay-3 {
  animation-delay: 0.22s;
}

.delay-4 {
  animation-delay: 0.3s;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .hero {
    flex-direction: column;
  }

  .theme-switch {
    width: 100%;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .top-banner {
    grid-template-columns: 1fr;
    left: 8px;
    right: 8px;
    top: 8px;
  }

  .banner-actions {
    flex-wrap: wrap;
  }

  .theme-dot-group {
    width: 100%;
    justify-content: center;
  }

  .mini-btn {
    width: 100%;
  }

  .btn.ghost {
    width: 100%;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    max-height: 90vh;
  }

  .sticky-wall {
    top: 144px;
    bottom: 84px;
  }

  body.app-mode .site-footer,
  body.app-mode .status {
    left: 8px;
    right: 8px;
  }

  .modal-actions {
    justify-content: stretch;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .history-row {
    flex-wrap: wrap;
  }

  .history-right {
    width: 100%;
    justify-content: flex-end;
  }
}
