:root {
  --ink: #16233a;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --surface-soft: #f5f1e8;
  --growth: #159c7a;
  --growth-dark: #0e6f59;
  --signal: #f09d1a;
  --line: #e3e0d8;
  --muted: #6b7280;
  --danger: #a64835;
  --shadow: 0 22px 60px rgba(22, 35, 58, 0.12);
  --radius: 8px;
}

body.theme-dark {
  --ink: #edf4ff;
  --paper: #101722;
  --surface: #172131;
  --surface-soft: #202d40;
  --growth: #37c99f;
  --growth-dark: #7ee4c5;
  --signal: #f4b84a;
  --line: #344258;
  --muted: #aeb9c9;
  --danger: #ffb3a3;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(251, 250, 247, 0.94), rgba(245, 241, 232, 0.92)),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

body.theme-dark {
  background:
    linear-gradient(180deg, rgba(16, 23, 34, 0.96), rgba(22, 31, 45, 0.94)),
    var(--paper);
}

.skip-link {
  position: fixed;
  left: 18px;
  top: 12px;
  z-index: 50;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--ink);
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  overflow: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

body.theme-dark .sidebar {
  background: rgba(16, 23, 34, 0.84);
}

.app-shell.sidebar-collapsed .sidebar {
  padding-right: 0;
  padding-left: 0;
  border-right: 0;
  opacity: 0;
  visibility: hidden;
}

.sidebar-edge-toggle {
  position: fixed;
  top: 28px;
  left: 268px;
  z-index: 30;
  display: grid;
  place-items: center;
  gap: 4px;
  width: 42px;
  height: 42px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(22, 35, 58, 0.12);
  transition: left 0.2s ease, background 0.2s ease;
}

.sidebar-edge-toggle:hover {
  background: var(--surface-soft);
}

.sidebar-edge-toggle:focus-visible {
  outline: 3px solid rgba(21, 156, 122, 0.26);
  outline-offset: 2px;
}

.sidebar-edge-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
}

.app-shell.sidebar-collapsed .sidebar-edge-toggle {
  left: 18px;
}

.app-shell.sidebar-collapsed .main {
  padding-left: 76px;
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--ink);
  font-weight: 800;
}

body.theme-dark .brand-mark,
body.theme-dark .segment.is-active,
body.theme-dark .solid-button {
  color: #101722;
  background: #edf4ff;
}

.brand strong,
.brand span {
  display: block;
}

.nav-item span span {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand span,
.nav-item small,
.date-line,
.eyebrow,
.privacy,
.sidebar-card p {
  color: var(--muted);
}

.brand span,
.nav-item small {
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  border-color: var(--line);
  background: var(--surface);
}

.nav-item.is-active {
  box-shadow: 0 8px 24px rgba(22, 35, 58, 0.08);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--growth-dark);
  font-weight: 800;
}

.nav-item.is-active .nav-icon {
  color: #fff;
  background: var(--growth);
}

.sidebar-card {
  margin-top: 26px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.sidebar-card p {
  margin: 8px 0 0;
  font-size: 13px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.date-line,
.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  margin-top: 4px;
  font-size: 34px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 17px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.role-badge {
  display: inline-grid;
  min-height: 38px;
  place-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--teal);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 850;
}

.export-menu {
  position: relative;
}

.export-choices {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 12;
  display: grid;
  min-width: 148px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.export-choices button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  font-weight: 750;
  text-align: left;
}

.export-choices button:hover {
  background: var(--surface-soft);
}

.segmented {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.segment,
.theme-toggle,
.ghost-button,
.solid-button,
.danger-button {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 750;
}

.segment {
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
}

.segment.is-active {
  color: #fff;
  background: var(--ink);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface);
  font-size: 20px;
  font-weight: 900;
}

.theme-toggle:hover {
  background: var(--surface-soft);
}

.ghost-button {
  padding: 0 14px;
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface);
}

.solid-button {
  padding: 0 15px;
  color: #fff;
  background: var(--ink);
}

.danger-button {
  padding: 0 12px;
  color: var(--danger);
  border-color: rgba(166, 72, 53, 0.25);
  background: #fff8f5;
}

body.theme-dark .danger-button {
  background: rgba(255, 179, 163, 0.12);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.workspace-grid {
  display: grid;
  gap: 18px;
}

.today-grid {
  grid-template-columns: minmax(360px, 1.12fr) minmax(320px, 0.88fr);
  align-items: start;
}

.hero-panel,
.panel,
.page-band {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 36px rgba(22, 35, 58, 0.07);
}

body.theme-dark .hero-panel,
body.theme-dark .panel,
body.theme-dark .page-band {
  background: rgba(23, 33, 49, 0.9);
  box-shadow: var(--shadow);
}

.hero-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(330px, 0.9fr) minmax(420px, 1.1fr);
  min-height: 300px;
  overflow: hidden;
}

.hero-copy {
  align-self: center;
  padding: 34px;
}

.hero-copy h2 {
  margin-top: 10px;
  font-size: 42px;
}

.hero-copy p {
  max-width: 620px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.hero-panel img {
  width: 100%;
  height: 100%;
  min-height: 300px;
  object-fit: cover;
}

body.theme-dark .hero-panel img {
  filter: saturate(0.92) brightness(0.82);
}

.panel {
  padding: 20px;
}

.panel-heading,
.page-band {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.panel-heading {
  margin-bottom: 16px;
}

.page-band {
  margin-bottom: 18px;
  padding: 22px;
}

.page-band p {
  max-width: 780px;
  margin: 8px 0 0;
  color: var(--muted);
}

.privacy {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

.privacy.private {
  color: var(--growth-dark);
  background: rgba(21, 156, 122, 0.08);
}

.privacy.family {
  color: #8a5b0a;
  background: rgba(240, 157, 26, 0.1);
}

.privacy.public {
  color: var(--ink);
  background: var(--surface-soft);
}

label,
.field-grid {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  outline: none;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #121b29;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(21, 156, 122, 0.65);
  box-shadow: 0 0 0 3px rgba(21, 156, 122, 0.12);
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.task-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 132px;
  gap: 10px;
  margin-bottom: 16px;
}

.task-panel {
  grid-column: 1 / -1;
}

.focus-panel {
  grid-column: 1 / -1;
}

.ai-log-panel {
  grid-column: 1 / -1;
}

.task-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.task-column {
  min-height: 220px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.task-column h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.task-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

body.theme-dark .task-count {
  background: #121b29;
}

.task-card,
.entry-card,
.project-card,
.rule-card,
.metric-card,
.mode-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

body.theme-dark .task-card,
body.theme-dark .entry-card,
body.theme-dark .project-card,
body.theme-dark .rule-card,
body.theme-dark .metric-card,
body.theme-dark .mode-card,
body.theme-dark .ghost-button,
body.theme-dark .icon-button,
body.theme-dark .theme-toggle,
body.theme-dark .segmented {
  background: #121b29;
}

.task-card {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 8px;
  align-items: start;
  margin-top: 10px;
  padding: 10px;
}

.task-card input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.task-card.is-done strong {
  color: var(--muted);
  text-decoration: line-through;
}

.task-card small {
  color: var(--muted);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mode-card {
  min-height: 116px;
  padding: 14px;
  width: 100%;
  color: var(--text);
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.mode-card:hover,
.mode-card:focus-visible {
  border-color: var(--growth);
  outline: none;
  transform: translateY(-1px);
}

.mode-card.is-selected {
  border-color: var(--growth);
  box-shadow: inset 0 0 0 1px var(--growth), 0 14px 28px rgba(20, 158, 120, 0.14);
}

.mode-card strong {
  display: block;
}

.mode-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.selected-mode {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 800;
}

.ai-response-field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.ai-response-field textarea {
  background: var(--surface-soft);
}

.sync-panel {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.sync-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.home-grid,
.journal-grid {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.78fr);
}

.timeline-panel {
  grid-column: 1 / -1;
}

.lead {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
}

.featured-work {
  margin-top: 10px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.featured-work p {
  margin-bottom: 0;
  color: var(--muted);
}

.timeline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.timeline span {
  color: var(--growth-dark);
  font-weight: 900;
}

.timeline p {
  margin: 0;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.compact-list {
  margin-top: 14px;
}

.entry-card,
.project-card,
.rule-card,
.metric-card {
  padding: 16px;
}

.entry-card p,
.project-card p,
.rule-card p,
.metric-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.review-summary {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.review-summary div {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.review-summary dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.review-summary dd {
  margin: 0;
  color: var(--text);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.project-form-panel {
  margin-bottom: 18px;
}

.risk-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(166, 72, 53, 0.25);
  border-radius: var(--radius);
  color: var(--danger);
  background: #fff8f5;
  font-weight: 750;
}

body.theme-dark .risk-panel {
  background: rgba(255, 179, 163, 0.1);
}

.search-panel {
  margin-bottom: 18px;
}

.search-input {
  max-width: 420px;
}

.project-card {
  min-height: 250px;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-strip {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: rgba(21, 156, 122, 0.1);
  color: var(--growth-dark);
  font-weight: 800;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.rule-card {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
}

.rule-number {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--growth);
  font-weight: 900;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card strong {
  display: block;
  font-size: 32px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.health-item,
.check-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.health-item strong,
.check-item strong {
  display: block;
}

.health-item p,
.check-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.privacy-checklist,
.publish-checklist {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.deleted-panel {
  margin-top: 18px;
}

.deleted-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.deleted-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.deleted-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.check-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
}

.check-item input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.question-grid p {
  margin: 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  font-weight: 750;
}

.muted-copy {
  margin: 0;
  color: var(--muted);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

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

.is-hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

body.theme-dark .toast {
  border-color: #4c5d78;
  background: #0b1220;
  color: #f8fbff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .today-grid,
  .hero-panel,
  .home-grid,
  .journal-grid {
    grid-template-columns: 1fr;
  }

  .hero-panel img {
    max-height: 360px;
  }

  .task-columns,
  .project-grid,
  .metric-grid,
  .health-grid,
  .question-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
  }

  .app-shell.sidebar-collapsed .sidebar {
    display: none;
  }

  .sidebar-edge-toggle {
    top: 26px;
    left: auto;
    right: 18px;
  }

  .app-shell.sidebar-collapsed .sidebar-edge-toggle {
    left: auto;
    right: 18px;
  }

  .app-shell.sidebar-collapsed .main {
    padding-left: 18px;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .main {
    padding: 18px;
  }

  .topbar,
  .page-band,
  .panel-heading {
    display: grid;
  }

  .top-actions,
  .task-form,
  .task-columns,
  .field-grid.two,
  .field-grid.three,
  .mode-grid,
  .timeline,
  .project-grid,
  .rule-grid,
  .metric-grid,
  .health-grid,
  .sync-grid,
  .question-grid {
    grid-template-columns: 1fr;
  }

  .top-actions {
    display: grid;
  }

  .hero-copy {
    padding: 24px;
  }

  .hero-copy h2 {
    font-size: 32px;
  }
}
