﻿:root {
  color-scheme: light;
  --bg: #f7f3ea;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --text: #24211d;
  --muted: #6f665b;
  --line: #ddd4c6;
  --accent: #2f6f73;
  --accent-soft: #dceeed;
  --warn: #a75922;
  --warn-soft: #f6e2d2;
  --ok: #55723a;
  --ok-soft: #e4edda;
  --shadow: 0 14px 36px rgba(47, 38, 25, 0.12);
  --reader-size: 1rem;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161718;
  --surface: #202224;
  --surface-strong: #282b2d;
  --text: #f1eee7;
  --muted: #b9b0a6;
  --line: #3b3f42;
  --accent: #7dc7c5;
  --accent-soft: #173b3d;
  --warn: #e2a06e;
  --warn-soft: #4a2f1e;
  --ok: #a9c982;
  --ok-soft: #29371f;
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 14px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toolbar {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.segmented,
.control-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

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

.segment,
.chip-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segment.is-active,
.chip-button.is-active {
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.search-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 0 12px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 2px 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

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

.note-card {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: 0 8px 20px rgba(47, 38, 25, 0.07);
}

.note-card.is-active {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}

.note-open {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.note-card-title {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.45;
}

.note-card-meta,
.status-label {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

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

.status-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.status-button.is-done {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}

.status-button.is-review {
  border-color: var(--warn);
  background: var(--warn-soft);
  color: var(--warn);
}

.status-button.is-clear {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.reader {
  margin-top: 16px;
  padding-bottom: 24px;
}

.reader-panel,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.reader-panel {
  overflow: hidden;
}

.reader-header {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.reader-header h2 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.4;
}

.reader-body {
  padding: 16px;
  font-size: var(--reader-size);
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.reader-body h1,
.reader-body h2,
.reader-body h3 {
  line-height: 1.35;
}

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

.reader-body img,
.reader-body svg,
.reader-body canvas,
.reader-body table {
  max-width: 100%;
}

.reader-body pre {
  overflow-x: auto;
  white-space: pre-wrap;
}

.empty-state {
  padding: 22px 16px;
  color: var(--muted);
}

.empty-state h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 1.05rem;
}

.empty-state p {
  margin: 0;
  line-height: 1.7;
}

body.font-small {
  --reader-size: 0.92rem;
}

body.font-large {
  --reader-size: 1.12rem;
}

@media (min-width: 720px) {
  .app {
    padding-inline: 22px;
  }

  .toolbar {
    grid-template-columns: 220px minmax(0, 1fr) 160px;
    align-items: end;
  }

  .note-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.diagram-panel {
  margin: 14px 0 16px;
  padding: 10px;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  background: color-mix(in srgb, var(--surface-strong) 92%, var(--accent-soft));
  -webkit-overflow-scrolling: touch;
}

.flow-diagram {
  display: block;
  width: 100%;
  min-width: 500px;
  height: auto;
}

.diagram-box {
  fill: var(--surface-strong);
  stroke: var(--text);
  stroke-width: 2;
}

.diagram-soft {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 2;
}

.diagram-line {
  fill: none;
  stroke: var(--text);
  stroke-width: 2.5;
}

.diagram-line-thin {
  stroke-width: 2;
}

.diagram-arrow-head {
  fill: var(--text);
}

.diagram-label {
  fill: var(--text);
  font-size: 20px;
  font-weight: 700;
}

.diagram-small {
  fill: var(--text);
  font-size: 17px;
}

.diagram-action-label {
  font-size: 23px;
  font-weight: 800;
}

@media (max-width: 520px) {
  .diagram-panel {
    margin-inline: -4px;
    padding: 8px;
  }
}



