:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --text: #182025;
  --muted: #66747c;
  --line: #dce4e8;
  --teal: #1f8a83;
  --teal-soft: #d8eeeb;
  --coral: #de6f58;
  --amber: #c28a26;
  --blue: #4377c7;
  --green: #4d9566;
  --shadow: 0 16px 36px rgba(24, 32, 37, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--text);
  color: white;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.1;
}

.brand p,
.panel p,
.topbar p,
.compact-field span,
.stat span,
.entry-meta,
.memory-meta {
  color: var(--muted);
}

.brand p {
  margin-top: 4px;
  font-size: 13px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav-item span:first-child {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--muted);
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.active span:first-child {
  color: var(--teal);
}

.sidebar-footer {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding: 0 8px;
}

.ghost-button,
.file-button,
.subtle-button,
.primary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.ghost-button,
.subtle-button {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.ghost-button:hover,
.subtle-button:hover {
  background: var(--surface-2);
}

.primary-button {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
  box-shadow: 0 8px 20px rgba(31, 138, 131, 0.18);
}

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

.danger-button {
  background: #fff3f0;
  color: #a94732;
  border-color: #f0c7bd;
}

#importData {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

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

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

.eyebrow {
  margin-bottom: 6px;
  font-size: 13px;
}

.topbar h2 {
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: #176861;
  font-size: 13px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.layout.two-column {
  display: grid;
  grid-template-columns: minmax(340px, 1.15fr) minmax(280px, 0.85fr);
  gap: 20px;
}

.view-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(280px, 0.82fr);
  gap: 20px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 20px;
  align-content: start;
}

.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.panel h3 {
  font-size: 18px;
  line-height: 1.25;
}

.panel p {
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.45;
}

.compact-field,
.journal-window {
  display: grid;
  gap: 7px;
}

.compact-field span,
.journal-window span {
  font-size: 13px;
  color: var(--muted);
}

.compact-field input,
.memory-form input,
.memory-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--text);
  outline: 0;
}

.compact-field input,
.memory-form input,
.memory-form select {
  height: 42px;
  padding: 0 12px;
}

.journal-window textarea {
  width: 100%;
  resize: vertical;
  min-height: 520px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--text);
  line-height: 1.7;
  outline: 0;
  font-size: 16px;
}

.journal-window textarea:focus,
.compact-field input:focus,
.memory-form input:focus,
.memory-form select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 138, 131, 0.13);
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.stat {
  display: grid;
  gap: 8px;
  min-height: 84px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.stat strong {
  font-size: 24px;
  line-height: 1;
}

.entry-list,
.memory-list,
.suggestion-list,
.theme-list,
.review-body,
#activePlan,
.day-plan-grid {
  display: grid;
  gap: 12px;
}

.entry-item,
.memory-item,
.suggestion-item,
.theme-item,
.plan-block,
.day-plan,
.review-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.entry-item,
.memory-item,
.suggestion-item,
.theme-item,
.review-card {
  padding: 14px;
}

.entry-top,
.memory-top,
.plan-task {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.entry-title,
.memory-text,
.suggestion-item strong,
.theme-item strong {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
}

.entry-copy,
.entry-reply-line,
.review-card p,
.suggestion-item p,
.theme-item p,
.plan-block p,
.day-plan p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.entry-reply-line {
  color: #176861;
}

.entry-meta,
.memory-meta {
  font-size: 12px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: #176861;
  font-size: 12px;
}

.tag.alt {
  background: #f7e6d0;
  color: #825914;
}

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

.reply-section {
  display: grid;
  gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.reply-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.reply-section h4 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.reply-section p,
.reply-section ul {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.reply-section ul {
  padding-left: 18px;
}

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

.icon-button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.review-card h4,
.plan-block h4,
.day-plan h4 {
  margin: 0;
  font-size: 15px;
}

.review-card ul,
.plan-block ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.suggestion-item {
  border-left: 4px solid var(--teal);
}

.suggestion-item:nth-child(2n) {
  border-left-color: var(--coral);
}

.suggestion-item:nth-child(3n) {
  border-left-color: var(--blue);
}

.memory-form {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 16px;
}

.memory-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.memory-kind {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.memory-item.pinned {
  border-color: #9bc8c3;
  background: #f3fbfa;
}

.plan-block {
  padding: 16px;
}

.focus-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.focus-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--text);
  color: white;
  font-size: 13px;
}

.task-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.plan-task {
  justify-content: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.plan-task input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.plan-task.done span {
  text-decoration: line-through;
  color: var(--muted);
}

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

.day-plan {
  min-height: 116px;
  padding: 14px;
}

.progress-bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--green));
}

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

.chart-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

#trendChart {
  display: block;
  width: 100%;
  min-height: 260px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 999px;
}

.dot.mood {
  background: var(--teal);
}

.dot.energy {
  background: var(--blue);
}

.dot.stress {
  background: var(--coral);
}

.rhythm-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.rhythm-day {
  display: grid;
  gap: 8px;
  align-content: end;
  min-height: 142px;
}

.rhythm-bar {
  align-self: end;
  min-height: 8px;
  border-radius: var(--radius);
  background: var(--teal);
  opacity: 0.88;
}

.rhythm-day span {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 148px;
  border: 1px dashed #c7d2d8;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

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

  .nav-item {
    justify-content: center;
    padding: 0 8px;
  }

  .nav-item span:first-child {
    display: none;
  }

  .sidebar-footer {
    margin-top: 0;
  }

  .layout.two-column,
  .view-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .main-area {
    padding: 18px;
  }

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

  .topbar h2 {
    font-size: 26px;
  }

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

  .stat-grid,
  .memory-form,
  .day-plan-grid,
  .rhythm-grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
  }

  .sidebar-footer {
    flex-wrap: wrap;
  }
}
