*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --paper: rgba(255, 255, 255, 0.92);
  --paper-muted: #f2f2f4;
  --hover: rgba(0, 0, 0, 0.055);
  --border: rgba(0, 0, 0, 0.14);
  --border-soft: rgba(0, 0, 0, 0.075);
  --ink: #1d1d1f;
  --muted: #606066;
  --faint: #8e8e93;
  --accent: #0a84ff;
  --accent-dark: #0066cc;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --sidebar: rgba(236, 236, 239, 0.78);
  --control: rgba(255, 255, 255, 0.78);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  --radius: 10px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  --mono: 'SF Mono', ui-monospace, Menlo, Monaco, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1f1f22;
    --paper: rgba(43, 43, 46, 0.92);
    --paper-muted: #303034;
    --hover: rgba(255, 255, 255, 0.075);
    --border: rgba(255, 255, 255, 0.16);
    --border-soft: rgba(255, 255, 255, 0.09);
    --ink: #f5f5f7;
    --muted: #c7c7cc;
    --faint: #8e8e93;
    --accent: #0a84ff;
    --accent-dark: #64b5ff;
    --accent-soft: rgba(10, 132, 255, 0.2);
    --sidebar: rgba(40, 40, 43, 0.76);
    --control: rgba(58, 58, 61, 0.86);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  }
}

body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,0.7), transparent 26%),
    linear-gradient(180deg, rgba(255,255,255,0.34), transparent 180px);
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
}

@media (prefers-color-scheme: dark) {
  .sidebar { background: var(--sidebar); }
}

.sidebar-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.traffic-lights {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  height: 14px;
  align-items: center;
  margin-bottom: 10px;
}

.traffic-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}
.traffic-light.red { background: #ff5f57; }
.traffic-light.yellow { background: #febc2e; }
.traffic-light.green { background: #28c840; }

.view-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin: 12px 14px;
  padding: 3px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background: rgba(0,0,0,0.055);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.05);
  border-bottom: 1px solid var(--border-soft);
}

.view-tab {
  height: 28px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}

.view-tab:hover { background: var(--hover); color: var(--ink); }
.view-tab.active {
  background: rgba(255,255,255,0.9);
  border-color: rgba(0,0,0,0.08);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.16);
}

.product-kicker {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: 2.4px;
}

h1 {
  margin-top: 2px;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.sync-badge {
  margin-top: 4px;
  padding: 2px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.sync-badge.saved { color: var(--accent-dark); border-color: rgba(10,132,255,0.22); background: var(--accent-soft); }
.sync-badge.error { color: #c8402e; border-color: rgba(200,64,46,0.35); }

.identity-panel {
  padding: 4px 14px 6px;
}

.identity-panel label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
}

.identity-panel select,
.search-wrap input,
.meta-pill select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--control);
  outline: none;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6), inset 0 1px 1px rgba(0,0,0,0.035);
}

.identity-panel select {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
  padding: 8px 14px;
}

.view-controls {
  padding: 8px 14px;
}

.sidebar-actions.view-controls {
  display: grid;
  grid-template-columns: 1fr 40px;
}

.date-control {
  width: 100%;
  height: 36px;
  margin-bottom: 8px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--control);
  outline: none;
  font-family: var(--mono);
  font-size: 12px;
}

.primary-action,
.icon-action {
  height: 34px;
  border: none;
  border-radius: 7px;
  transition: transform 0.18s var(--ease), opacity 0.18s var(--ease), background 0.18s var(--ease);
}

.primary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(#0a84ff, #0071e3);
  color: white;
  font-size: 13px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 1px 2px rgba(0,0,0,0.15);
}

.primary-action:hover,
.icon-action:hover { transform: translateY(-1px); }
.primary-action svg { width: 16px; height: 16px; }

.icon-action {
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--control);
  color: var(--muted);
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 10px;
  color: var(--faint);
}

.search-wrap svg { width: 15px; height: 15px; flex: none; }
.search-wrap input {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}
.search-wrap input:focus { border-color: rgba(10,132,255,0.55); }

.page-list {
  flex: 1;
  overflow: auto;
  padding: 2px 8px 18px;
}

.group-header,
.page-row,
.list-row {
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 7px;
  color: var(--ink);
  text-align: left;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 4px 0;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.group-header:hover,
.page-row:hover,
.list-row:hover { background: var(--hover); }
.group-header .chevron { width: 12px; height: 12px; transition: transform 0.18s var(--ease); }
.group-header.collapsed .chevron { transform: rotate(-90deg); }
.group-count { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--faint); }

.page-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 5px 8px;
  font-size: 13px;
  transition: background 0.14s var(--ease), box-shadow 0.14s var(--ease);
}

.list-row {
  display: block;
  margin-bottom: 2px;
  padding: 8px 10px;
  transition: background 0.14s var(--ease), box-shadow 0.14s var(--ease);
}

.list-row.active {
  background: rgba(10, 132, 255, 0.14);
  box-shadow: none;
}

.list-row-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.list-row-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
  color: var(--faint);
  font-size: 11px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--paper-muted);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.status-chip.active,
.status-chip.working,
.status-chip.in_progress { background: rgba(52,199,89,0.15); color: #248a3d; }
.status-chip.done,
.status-chip.completed,
.status-chip.submitted { background: rgba(10,132,255,0.14); color: var(--accent-dark); }
.status-chip.overdue,
.status-chip.cancelled { background: rgba(255,59,48,0.14); color: #d70015; }

.page-row.active {
  background: rgba(10, 132, 255, 0.14);
  box-shadow: none;
}

.tree-toggle,
.tree-add {
  flex: none;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--faint);
}

.tree-toggle:hover,
.tree-add:hover { color: var(--accent-dark); background: var(--accent-soft); }
.tree-toggle svg { width: 11px; height: 11px; transition: transform 0.16s var(--ease); }
.tree-toggle.open svg { transform: rotate(90deg); }
.page-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tree-add { margin-left: auto; opacity: 0; }
.page-row:hover .tree-add { opacity: 1; }

.workspace {
  min-width: 0;
  padding: 44px 56px 76px;
  background: var(--bg);
}

.empty-state {
  min-height: calc(100vh - 124px);
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
  animation: fadeUp 0.42s var(--ease) both;
}

.empty-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--faint);
  background: var(--paper);
}

.empty-state h2 {
  font-size: 20px;
  color: var(--ink);
}

.empty-state p {
  margin-top: 6px;
  font-size: 13px;
}

.editor {
  max-width: 930px;
  margin: 0 auto;
  animation: fadeUp 0.36s var(--ease) both;
}

.report-hero,
.project-hero {
  margin-bottom: 20px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--faint);
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.report-title,
.project-title-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: clamp(30px, 4.7vw, 48px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0;
}

.project-title-input {
  min-height: 54px;
  resize: none;
  overflow: hidden;
}

.project-desc-input,
.report-note {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--paper);
  outline: none;
  color: var(--ink);
  resize: vertical;
}

.project-desc-input {
  min-height: 56px;
  margin-top: 10px;
  padding: 12px 14px;
  color: var(--muted);
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.field-card {
  min-width: 0;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 1px 1px rgba(0,0,0,0.025);
}

@media (prefers-color-scheme: dark) {
  .project-desc-input,
  .report-note,
  .field-card { background: rgba(25,25,23,0.5); }
  .status-chip.active,
  .status-chip.working,
  .status-chip.in_progress { background: rgba(48,209,88,0.18); color: #30d158; }
  .status-chip.overdue,
  .status-chip.cancelled { background: rgba(255,69,58,0.18); color: #ff6961; }
}

.field-label {
  margin-bottom: 6px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.field-card input,
.field-card select {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}

.section-block {
  margin: 26px 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 13px;
  line-height: 1.3;
}

.text-button {
  border: none;
  background: transparent;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.task-list {
  display: grid;
  gap: 7px;
}

.task-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 34px;
  align-items: start;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background: var(--paper);
}

.task-item.done { opacity: 0.62; }
.task-item.done .task-text { text-decoration: line-through; color: var(--faint); }

.task-check {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: 4px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--control);
}

.task-check:checked {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 4px var(--paper);
}

.task-text {
  width: 100%;
  min-height: 29px;
  border: none;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  line-height: 1.65;
}

.icon-button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
}

.icon-button:hover { background: var(--hover); color: #c8402e; }

.report-note {
  min-height: 130px;
  padding: 14px;
  line-height: 1.8;
}

.submit-button {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(#0a84ff, #0071e3);
  color: white;
  font-weight: 700;
  transition: transform 0.18s var(--ease), opacity 0.18s var(--ease);
}

.submit-button:hover { transform: translateY(-1px); }
.submit-button.submitted {
  border: 1px solid rgba(10,132,255,0.22);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.progress-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin: 18px 0 28px;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border-soft);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0a84ff, #64d2ff);
  transition: width 0.28s var(--ease);
}

.project-task-row {
  display: grid;
  grid-template-columns: 106px minmax(0, 1fr) 116px 126px 32px;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
}

.project-task-row input,
.project-task-row select,
.project-task-row textarea {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  background: var(--paper);
  outline: none;
  padding: 7px 8px;
  font-size: 12px;
}

.project-task-row textarea {
  grid-column: 2 / 5;
  resize: vertical;
  min-height: 42px;
  line-height: 1.6;
}

.delete-zone {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
  color: var(--faint);
  font-size: 12px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 24px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--faint);
}

.breadcrumbs button {
  border: none;
  border-radius: 5px;
  padding: 2px 5px;
  background: transparent;
  color: var(--muted);
}
.breadcrumbs button:hover { background: var(--hover); color: var(--accent-dark); }

.editor-title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.page-icon {
  flex: none;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 32px;
  line-height: 1;
  transition: transform 0.16s var(--ease), background 0.16s var(--ease);
}
.page-icon:hover { transform: scale(1.05); background: var(--hover); }

.title-input {
  flex: 1;
  min-height: 54px;
  resize: none;
  border: none;
  outline: none;
  overflow: hidden;
  background: transparent;
  color: var(--ink);
  font-size: clamp(30px, 4.7vw, 48px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0;
}
.title-input::placeholder { color: var(--faint); opacity: 0.5; }

.meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 18px 66px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--faint);
}

@media (prefers-color-scheme: dark) {
  .meta-pill { background: var(--paper); }
}

.meta-pill svg { width: 14px; height: 14px; }
.meta-pill select {
  width: auto;
  max-width: 220px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.updated-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}

.toolbar-wrap {
  position: sticky;
  top: 12px;
  z-index: 10;
  height: 0;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}
.toolbar-wrap.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

.toolbar {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.toolbar button {
  min-width: 30px;
  height: 28px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.toolbar button:hover { color: var(--ink); background: var(--hover); }
.toolbar span {
  width: 1px;
  height: 16px;
  margin: 0 4px;
  background: var(--border-soft);
}
.toolbar svg { width: 15px; height: 15px; }

.content-editor {
  min-height: 320px;
  padding: 12px 0 10px 66px;
  outline: none;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.72;
}
.content-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--faint);
  opacity: 0.65;
}
.content-editor h1 { margin: 24px 0 8px; font-size: 1.72em; line-height: 1.3; }
.content-editor h2 { margin: 22px 0 8px; font-size: 1.36em; line-height: 1.35; }
.content-editor h3 { margin: 18px 0 6px; font-size: 1.12em; line-height: 1.45; }
.content-editor p { margin: 8px 0; }
.content-editor ul,
.content-editor ol { padding-left: 24px; margin: 8px 0; }
.content-editor blockquote {
  margin: 14px 0;
  padding: 6px 16px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  background: var(--accent-soft);
}
.content-editor code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--paper-muted);
  font-family: var(--mono);
  font-size: 0.9em;
}
.content-editor pre {
  overflow-x: auto;
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--paper-muted);
  font-family: var(--mono);
  font-size: 13px;
}
.content-editor a { color: var(--accent-dark); text-underline-offset: 2px; }
.content-editor img { max-width: 100%; border-radius: var(--radius); }

.subpages {
  margin: 28px 0 0 66px;
}
.subpages-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.subpages-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.small-button {
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.small-button:hover { color: var(--accent-dark); border-color: rgba(10,132,255,0.45); }
.subpage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.subpage-card {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--paper);
  text-align: left;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.subpage-card:hover {
  transform: translateY(-2px);
  border-color: rgba(10,132,255,0.45);
  box-shadow: var(--shadow);
}
.subpage-icon { font-size: 22px; }
.subpage-title { font-size: 13px; font-weight: 700; color: var(--ink); }
.subpage-preview {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.subpage-date {
  margin-top: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 56px 0 0 66px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
  color: var(--faint);
  font-size: 12px;
}

.delete-button {
  border: none;
  background: transparent;
  color: var(--faint);
  font-size: 12px;
}
.delete-button:hover { color: #c8402e; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  transform: translate(-50%, 12px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(44,44,46,0.92);
  color: white;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sidebar-toggle,
.sidebar-scrim { display: none; }

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

@media (max-width: 840px) {
  .app-shell { display: block; }
  .sidebar-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 80;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
  border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--shadow);
  }
  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(0,0,0,0.32);
  }
  .sidebar-scrim.visible { display: block; }
  .sidebar {
    position: fixed;
    z-index: 70;
    width: min(86vw, 314px);
    transform: translateX(-105%);
    transition: transform 0.24s var(--ease);
  }
  .sidebar.open { transform: translateX(0); }
  .workspace { padding: 70px 20px 52px; }
  .panel-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .project-task-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 30px;
    gap: 8px;
    padding: 12px 0;
  }
  .project-task-row [data-task-field="title"] {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .project-task-row [data-task-field="status"] {
    grid-column: 1;
    grid-row: 2;
  }
  .project-task-row [data-task-field="assignee"] {
    grid-column: 2;
    grid-row: 2;
  }
  .project-task-row [data-task-field="due_date"] {
    grid-column: 1 / 3;
    grid-row: 3;
  }
  .project-task-row [data-delete-task] {
    grid-column: 3;
    grid-row: 2 / 4;
    align-self: center;
  }
  .project-task-row textarea {
    grid-column: 1 / -1;
    grid-row: 4;
  }
  .editor-title-row { gap: 8px; }
  .page-icon { width: 42px; height: 42px; font-size: 30px; }
  .title-input { min-height: 50px; font-size: 34px; }
  .meta-row,
  .content-editor,
  .subpages,
  .editor-footer { margin-left: 0; padding-left: 0; }
  .meta-row { margin-top: 10px; }
  .content-editor { padding-top: 18px; }
  .editor-footer { flex-direction: column; align-items: flex-start; }
}

/* Notion-style refinement pass */
:root {
  --bg: #ffffff;
  --paper: #ffffff;
  --paper-muted: #f7f7f5;
  --hover: rgba(55, 53, 47, 0.08);
  --border: rgba(55, 53, 47, 0.16);
  --border-soft: rgba(55, 53, 47, 0.09);
  --ink: #37352f;
  --muted: rgba(55, 53, 47, 0.72);
  --faint: rgba(55, 53, 47, 0.45);
  --accent: #37352f;
  --accent-dark: #37352f;
  --accent-soft: rgba(55, 53, 47, 0.08);
  --sidebar: #f7f7f5;
  --control: #ffffff;
  --shadow: 0 10px 30px rgba(15, 15, 15, 0.08);
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --paper: #202020;
    --paper-muted: #252525;
    --hover: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.16);
    --border-soft: rgba(255, 255, 255, 0.09);
    --ink: rgba(255, 255, 255, 0.91);
    --muted: rgba(255, 255, 255, 0.66);
    --faint: rgba(255, 255, 255, 0.38);
    --accent: rgba(255, 255, 255, 0.88);
    --accent-dark: rgba(255, 255, 255, 0.88);
    --accent-soft: rgba(255, 255, 255, 0.1);
    --sidebar: #202020;
    --control: #252525;
  }
}

html,
body {
  width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  font-size: 14px;
}

body::before {
  display: none;
}

button,
input,
select,
textarea {
  max-width: 100%;
}

.app-shell {
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-right-color: var(--border-soft);
}

.traffic-lights {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  padding: 18px 14px 10px;
  border-bottom: none;
}

.product-kicker {
  display: none;
}

h1 {
  font-size: 18px;
  font-weight: 700;
}

.sync-badge {
  margin-left: auto;
  border: none;
  background: var(--accent-soft);
  color: var(--faint);
  font-family: var(--font);
  font-size: 11px;
}

.view-tabs {
  margin: 4px 8px 10px;
  padding: 0;
  gap: 1px;
  border: none;
  background: transparent;
  box-shadow: none;
}

.view-tab {
  height: 30px;
  border: none;
  border-radius: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.view-tab.active {
  background: var(--hover);
  border: none;
  box-shadow: none;
  color: var(--ink);
}

.identity-panel,
.view-controls,
.sidebar-actions,
.search-wrap {
  padding-left: 10px;
  padding-right: 10px;
}

.identity-panel label,
.field-label,
.eyebrow {
  color: var(--faint);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.identity-panel select,
.search-wrap input,
.date-control,
.project-task-row input,
.project-task-row select,
.project-task-row textarea,
.meta-pill,
.small-button {
  box-shadow: none;
}

.identity-panel select,
.search-wrap input,
.date-control {
  height: 32px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

@media (prefers-color-scheme: dark) {
  .identity-panel select,
  .search-wrap input,
  .date-control {
    background: rgba(255, 255, 255, 0.06);
  }
}

.identity-panel select:hover,
.search-wrap input:hover,
.date-control:hover,
.identity-panel select:focus,
.search-wrap input:focus,
.date-control:focus {
  border-color: var(--border);
  background: var(--paper);
}

.primary-action {
  height: 32px;
  justify-content: flex-start;
  padding: 0 10px;
  border-radius: 5px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: none;
  font-size: 13px;
}

.primary-action:hover,
.icon-action:hover {
  transform: none;
  background: var(--hover);
  color: var(--ink);
}

.icon-action {
  height: 32px;
  border: none;
  border-radius: 5px;
  background: transparent;
}

.page-list {
  padding: 0 8px 18px;
}

.group-header,
.page-row,
.list-row {
  border-radius: 5px;
}

.list-row,
.page-row {
  min-height: 30px;
}

.list-row {
  padding: 7px 8px;
}

.list-row-title,
.page-label {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row.active,
.page-row.active {
  background: rgba(55, 53, 47, 0.09);
}

@media (prefers-color-scheme: dark) {
  .list-row.active,
  .page-row.active {
    background: rgba(255, 255, 255, 0.1);
  }
}

.status-chip {
  height: 18px;
  border-radius: 4px;
  background: rgba(55, 53, 47, 0.08);
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.status-chip.active,
.status-chip.working,
.status-chip.in_progress,
.status-chip.done,
.status-chip.completed,
.status-chip.submitted {
  background: rgba(35, 131, 226, 0.13);
  color: #1d6fb8;
}

.status-chip.overdue,
.status-chip.cancelled {
  background: rgba(224, 62, 62, 0.12);
  color: #c23838;
}

.workspace {
  min-width: 0;
  padding: 52px clamp(24px, 7vw, 88px) 84px;
  background: var(--bg);
}

.editor {
  width: min(100%, 920px);
  max-width: 920px;
}

.report-title,
.project-title-input,
.title-input {
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.report-hero,
.project-hero {
  margin-bottom: 18px;
}

.project-desc-input,
.report-note,
.field-card,
.task-item,
.subpage-card {
  background: var(--paper);
  box-shadow: none;
}

.project-desc-input,
.report-note {
  border: 1px solid transparent;
  border-radius: 5px;
}

.project-desc-input:hover,
.report-note:hover,
.project-desc-input:focus,
.report-note:focus {
  border-color: var(--border-soft);
  background: var(--paper-muted);
}

.panel-grid {
  gap: 2px;
  margin: 16px 0 26px;
}

.field-card {
  min-height: 58px;
  border: none;
  border-radius: 5px;
  padding: 8px 10px;
}

.field-card:hover {
  background: var(--paper-muted);
}

.field-card input,
.field-card select {
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
}

.section-block {
  margin: 28px 0;
}

.section-heading {
  min-height: 32px;
  margin-bottom: 4px;
}

.section-heading h2 {
  font-size: 15px;
  font-weight: 700;
}

.text-button {
  border-radius: 5px;
  padding: 4px 6px;
  color: var(--faint);
  font-weight: 600;
}

.text-button:hover {
  background: var(--hover);
  color: var(--ink);
}

.task-list {
  gap: 1px;
}

.task-item {
  border: none;
  border-radius: 5px;
  padding: 5px 6px;
}

.task-item:hover {
  background: var(--paper-muted);
}

.task-check {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: transparent;
}

.task-check:checked {
  background: var(--ink);
  border-color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--paper);
}

.task-text {
  min-height: 26px;
  line-height: 1.55;
}

.submit-button {
  height: 40px;
  border-radius: 5px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: none;
}

.submit-button:hover {
  transform: none;
  opacity: 0.88;
}

.submit-button.submitted {
  border: none;
  background: var(--accent-soft);
  color: var(--ink);
}

.progress-line {
  margin: 16px 0 26px;
}

.progress-fill {
  background: var(--ink);
}

.project-task-row {
  grid-template-columns: minmax(88px, 112px) minmax(180px, 1fr) minmax(96px, 126px) minmax(118px, 140px) 28px;
  gap: 6px;
  align-items: start;
  padding: 6px 0;
}

.project-task-row input,
.project-task-row select,
.project-task-row textarea {
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  padding: 6px 7px;
  font-size: 13px;
}

.project-task-row:hover input,
.project-task-row:hover select,
.project-task-row:hover textarea,
.project-task-row input:focus,
.project-task-row select:focus,
.project-task-row textarea:focus {
  border-color: var(--border-soft);
  background: var(--paper-muted);
}

.project-task-row textarea {
  grid-column: 2 / 5;
  min-height: 38px;
}

.delete-zone,
.editor-footer {
  color: var(--faint);
  border-top-color: var(--border-soft);
}

.page-icon {
  width: 44px;
  height: 44px;
  font-size: 31px;
}

.editor-title-row {
  min-width: 0;
}

.meta-row {
  margin: 6px 0 18px 56px;
}

.meta-pill {
  border: none;
  border-radius: 5px;
  background: transparent;
}

.meta-pill:hover {
  background: var(--hover);
}

.content-editor {
  padding-left: 56px;
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.subpages,
.editor-footer {
  margin-left: 56px;
}

.toolbar {
  border-color: var(--border-soft);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(15, 15, 15, 0.12);
}

.small-button,
.subpage-card {
  border-color: var(--border-soft);
}

.small-button:hover,
.subpage-card:hover {
  border-color: var(--border);
  box-shadow: none;
  transform: none;
}

@media (max-width: 1100px) {
  .workspace {
    padding-left: 38px;
    padding-right: 38px;
  }

  .project-task-row {
    grid-template-columns: minmax(0, 1fr) minmax(96px, 130px) minmax(118px, 140px) 28px;
  }

  .project-task-row [data-task-field="title"] {
    grid-column: 1 / -1;
  }

  .project-task-row textarea {
    grid-column: 1 / -1;
  }
}

@media (max-width: 840px) {
  .workspace {
    padding: 66px 20px 52px;
  }

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

  .report-title,
  .project-title-input,
  .title-input {
    font-size: clamp(30px, 9vw, 40px);
  }

  .project-task-row {
    grid-template-columns: minmax(0, 1fr) 28px;
  }

  .project-task-row [data-task-field="title"],
  .project-task-row [data-task-field="status"],
  .project-task-row [data-task-field="assignee"],
  .project-task-row [data-task-field="due_date"],
  .project-task-row textarea {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .project-task-row [data-delete-task] {
    grid-column: 2;
    grid-row: 1;
  }

  .meta-row,
  .content-editor,
  .subpages,
  .editor-footer {
    margin-left: 0;
    padding-left: 0;
  }

  .content-editor {
    font-size: 15px;
  }
}
