:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --panel-muted: #fbfbfa;
  --line: #e7e7e3;
  --line-strong: #d9d9d3;
  --text: #1f2320;
  --muted: #6b726d;
  --subtle: #8e948f;
  --accent: #1f6a43;
  --accent-soft: #e8f4ed;
  --danger: #b54545;
  --danger-soft: #fbeeee;
  --warning: #8d651c;
  --warning-soft: #fbf4e5;
  --shadow: 0 8px 24px rgba(19, 24, 21, 0.04);
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-width: 248px;
  --content-max: 1160px;
  --row-height: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

button,
input,
select,
textarea {
  outline: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: 0 0 0 3px rgba(31, 106, 67, 0.14);
}

a {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  max-width: calc(var(--content-max) + 48px);
  margin: 0 auto;
  padding: 20px 24px 96px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand-block {
  display: grid;
  gap: 4px;
}

.brand-kicker {
  color: var(--subtle);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
}

.status-line {
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  gap: 20px;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 16px;
}

.sidebar-section {
  display: grid;
  gap: 12px;
}

.sidebar-card,
.surface,
.auth-card,
.overlay-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.sidebar-card {
  padding: 14px;
}

.sidebar-eyebrow {
  margin-bottom: 10px;
  color: var(--subtle);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav,
.sidebar-metrics {
  display: grid;
  gap: 6px;
}

.auth-shell {
  padding-top: 48px;
}

.nav-button,
.mobile-nav-button,
.chip-button,
.button,
.list-row-button,
.plain-button,
.quick-link {
  border: 0;
  background: transparent;
}

.nav-button,
.mobile-nav-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  transition: background-color 160ms ease, color 160ms ease;
}

.nav-button.active,
.mobile-nav-button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-button:hover,
.mobile-nav-button:hover,
.chip-button:hover,
.list-row-button:hover,
.plain-button:hover,
.quick-link:hover {
  background-color: rgba(31, 106, 67, 0.04);
}

.metric-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-muted);
}

.metric-label {
  color: var(--subtle);
  font-size: 12px;
}

.metric-value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.content-shell {
  display: grid;
}

.view-screen {
  display: grid;
  gap: 16px;
}

.surface {
  padding: 18px;
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.view-heading {
  display: grid;
  gap: 4px;
}

.view-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.view-subtitle,
.muted,
.hint,
.meta-line,
.empty-text {
  color: var(--muted);
}

.view-subtitle,
.meta-line {
  font-size: 14px;
}

.toolbar,
.cluster,
.row-meta,
.row-actions,
.compact-actions,
.floating-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.chip-button.active {
  border-color: rgba(31, 106, 67, 0.18);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.button:active {
  transform: translateY(1px);
}

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

.button-primary:hover {
  background: #195938;
}

.button-secondary {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}

.button-secondary:hover,
.button-ghost:hover {
  background: rgba(31, 106, 67, 0.04);
}

.button-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.button-danger:hover {
  background: #f8e8e8;
}

.button-ghost {
  color: var(--muted);
}

.section-stack,
.stack {
  display: grid;
  gap: 14px;
}

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

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

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

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

.inline-input {
  min-height: 38px;
  padding: 8px 10px;
}

.empty-state {
  display: grid;
  gap: 8px;
  place-items: start;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--panel-muted);
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
}

.list-shell {
  overflow: hidden;
  padding: 0;
}

.list-shell + .list-shell {
  margin-top: 14px;
}

.task-list,
.template-list,
.page-list,
.goal-list,
.diary-list,
.source-list,
.log-list {
  display: grid;
}

.task-row,
.template-row,
.page-row,
.goal-row,
.source-row {
  min-height: var(--row-height);
  display: grid;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.task-row:last-child,
.template-row:last-child,
.page-row:last-child,
.goal-row:last-child,
.source-row:last-child {
  border-bottom: 0;
}

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

.template-row,
.page-row,
.goal-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.list-row-button {
  width: 100%;
  display: block;
  padding: 0;
  text-align: left;
}

.task-main,
.row-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.task-title,
.row-title,
.diary-title,
.detail-title {
  font-size: 14px;
  font-weight: 600;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-subtitle,
.tag,
.mini-meta,
.diary-meta {
  font-size: 12px;
  color: var(--muted);
}

.status-toggle {
  width: 18px;
  height: 18px;
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.badge-neutral {
  background: #f2f3f1;
  color: var(--muted);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.goal-progress {
  display: grid;
  gap: 8px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #efefec;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.two-pane {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
}

.editor-shell {
  min-height: 560px;
}

.editor-column {
  max-width: 780px;
}

.editor-textarea {
  min-height: 420px;
  line-height: 1.6;
}

.diary-day {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.diary-day:last-child {
  border-bottom: 0;
}

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

.diary-items {
  display: grid;
  gap: 10px;
}

.detail-grid {
  display: grid;
  gap: 16px;
}

.detail-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-muted);
}

.chart-frame {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.chart {
  display: block;
  width: 100%;
  height: 240px;
}

.overlay-root {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 20, 18, 0.34);
  opacity: 0;
  transition: opacity 180ms ease;
}

.overlay-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(100%, 520px);
  padding: 18px;
  border-radius: 0;
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 180ms ease;
  overflow: auto;
  pointer-events: auto;
}

.overlay-panel.modal {
  top: 50%;
  left: 50%;
  right: auto;
  width: min(calc(100% - 24px), 560px);
  height: auto;
  max-height: min(88vh, 760px);
  border: 1px solid var(--line);
  border-radius: 16px;
  transform: translate(-50%, calc(-50% + 12px));
}

.overlay-panel.visible {
  transform: translateX(0);
}

.overlay-panel.modal.visible {
  transform: translate(-50%, -50%);
}

.overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.overlay-title {
  font-size: 20px;
  font-weight: 700;
}

.overlay-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.overlay-body {
  display: grid;
  gap: 14px;
}

.advanced-block {
  padding-top: 4px;
}

.disclosure {
  display: grid;
  gap: 12px;
}

.disclosure > summary {
  list-style: none;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure-toggle {
  justify-self: start;
}

.hidden {
  display: none !important;
}

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: #f0f1ef;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
  animation: shimmer 1.3s infinite;
}

.skeleton-row {
  height: var(--row-height);
  border-radius: 0;
  border-bottom: 1px solid var(--line);
}

.skeleton-card {
  height: 140px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(31, 35, 32, 0.92);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.12);
}

.mobile-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
}

.quick-add-button {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 22;
  display: none;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  box-shadow: 0 12px 20px rgba(31, 106, 67, 0.2);
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

@media (max-width: 980px) {
  .workspace,
  .two-pane,
  .split,
  .triple {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .editor-shell {
    min-height: auto;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 16px 16px 110px;
  }

  .workspace {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .mobile-nav {
    display: grid;
  }

  .quick-add-button {
    display: inline-flex;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-meta {
    align-items: flex-end;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .brand-title {
    font-size: 22px;
  }

  .surface {
    padding: 14px;
  }

  .view-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .task-row,
  .template-row,
  .page-row,
  .goal-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .row-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .overlay-panel {
    width: 100%;
  }

  .overlay-panel.modal {
    width: calc(100% - 12px);
  }
}
