/* workingsoba — theme tokens live in /styles/tokens.css (link it first). */
/* —— Base —— */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-glow-1) 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, var(--bg-glow-2) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-mid) 0%, var(--paper) 40%, var(--bg-end) 100%);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.suite-topbar,
.app-main {
  position: relative;
  z-index: 1;
}

.suite-topbar {
  position: relative;
  width: min(720px, calc(100% - 2rem));
  margin: calc(1rem + env(safe-area-inset-top, 0px)) auto 0;
  margin-bottom: 0;
  z-index: 40;
}

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--ink);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-ghost:hover {
  background: var(--card-bg-soft);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
}

.app-main {
  width: min(720px, calc(100% - 2rem));
  margin: 1.25rem auto 0;
}

.tab-page[hidden] {
  display: none !important;
}

.page-sub,
.hint {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.panel {
  background: var(--card-bg);
  padding: 1rem;
}

.panel + .panel {
  margin-top: 0.85rem;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.input,
textarea.input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  outline: none;
}

.input:focus,
textarea.input:focus {
  border-color: rgba(var(--accent-rgb), 0.55);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

textarea.input {
  resize: vertical;
  min-height: 4.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.field > span {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.65rem 0;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-bg-soft);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.chip.is-active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.chip--project.is-active { background: #3b6ea5; }
.chip--area.is-active { background: #2f7a4f; }
.chip--resource.is-active { background: #b07a28; }
.chip--archive.is-active { background: #6b7280; }
.chip--inbox.is-active { background: var(--accent); }

.bucket-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
  background: var(--muted);
}

.bucket-dot--inbox { background: var(--accent); }
.bucket-dot--project { background: #3b6ea5; }
.bucket-dot--area { background: #2f7a4f; }
.bucket-dot--resource { background: #b07a28; }
.bucket-dot--archive { background: #6b7280; }

.capture-form {
  display: grid;
  gap: 0.65rem;
}

.capture-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.item-list,
.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.item-card,
.project-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.item-card:hover,
.project-card:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
}

.item-card:active,
.project-card:active {
  transform: scale(0.99);
}

.item-card-main,
.project-card-main {
  min-width: 0;
  flex: 1;
}

.item-title,
.project-name {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
  word-break: break-word;
}

.item-note,
.item-meta,
.project-meta {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  -webkit-line-clamp: unset;
}

.empty-hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.review-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.review-stat:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.review-stat strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 650;
}

.file-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin: 0.75rem 0 1rem;
}

.file-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card-bg-soft);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.75rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  color: var(--ink);
  text-align: center;
}

.file-btn:hover {
  border-color: rgba(var(--accent-rgb), 0.45);
}

.file-btn.is-active {
  color: #fff;
  border-color: transparent;
}

.file-btn--project.is-active { background: #3b6ea5; }
.file-btn--area.is-active { background: #2f7a4f; }
.file-btn--resource.is-active { background: #b07a28; }
.file-btn--archive.is-active { background: #6b7280; }
.file-btn--inbox.is-active { background: var(--accent); }

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(0.75rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(720px, calc(100% - 1.5rem));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  z-index: 50;
}

.nav-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 0.55rem 0.25rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.nav-btn.is-active {
  background: var(--accent);
  color: var(--nav-active-fg);
}

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  margin-left: 0.2rem;
  padding: 0 0.3rem;
  border-radius: var(--radius-pill);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.68rem;
  font-weight: 700;
}

.nav-btn.is-active .badge-count {
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 80;
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

.sheet-backdrop[hidden] {
  display: none !important;
}

.sheet {
  width: min(520px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.15rem 1.25rem;
  box-shadow: var(--shadow);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.sheet h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 650;
}

.settings-block {
  margin-bottom: 1.1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}

.settings-block:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-block h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 650;
}

.status {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.status.is-ok {
  color: var(--ok);
}

.status.is-error {
  color: var(--danger);
}

.project-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-end;
}

.project-status {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.project-status.is-active {
  color: var(--ok);
}

.project-status.is-done {
  color: var(--muted);
}

@media (max-width: 480px) {
  .page-head.row {
    flex-direction: column;
  }

  .file-grid {
    grid-template-columns: 1fr;
  }
}

/* —— Viewer extras —— */

.demo-banner {
  position: relative;
  z-index: 30;
  width: min(720px, calc(100% - 2rem));
  margin: 0.75rem auto 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--warn);
  background: var(--warn-soft);
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.4;
}

.demo-banner-warn {
  display: block;
  margin-top: 0.25rem;
  font-weight: 650;
  color: var(--warn);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.stat-card {
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
}

.stat-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.stat-extra {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.list-section-label {
  list-style: none;
  margin: 0.75rem 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.note-body {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink);
}

.note-body h1,
.note-body h2,
.note-body h3 {
  font-family: var(--font-display);
  margin: 1rem 0 0.4rem;
  line-height: 1.25;
}

.note-body h1 { font-size: 1.35rem; }
.note-body h2 { font-size: 1.15rem; }
.note-body h3 { font-size: 1.02rem; }

.note-body p { margin: 0.4rem 0; }
.note-body ul { margin: 0.35rem 0 0.35rem 1.1rem; padding: 0; }
.note-body li { margin: 0.2rem 0; }

.note-body .wiki-link {
  color: var(--accent-deep);
  font-weight: 600;
}

.note-body .task-line {
  margin: 0.25rem 0;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--muted-surface);
}

.note-body .task-line.is-done {
  opacity: 0.65;
  text-decoration: line-through;
}

.note-body a {
  color: var(--accent-deep);
}

.bottom-nav-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (min-width: 560px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
