:root {
  --bg: #f8f5ee;
  --paper: #fffdf7;
  --ink: #222222;
  --muted: #697386;
  --line: #222222;
  --shadow: 7px 7px 0 #222222;
  --radius: 22px;
  --card-text-size: clamp(0.88rem, 0.55vw + 0.72rem, 1.03rem);
  --card-title-size: clamp(1rem, 0.7vw + 0.85rem, 1.2rem);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 214, 102, 0.18), transparent 28%),
    radial-gradient(circle at 85% 25%, rgba(113, 203, 255, 0.15), transparent 26%),
    var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

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

button {
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
  padding: 0.7rem 1rem;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--line);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--line);
}

button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

button.primary {
  background: #d7f7d0;
}

button.danger {
  background: #ffe1df;
}

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

code {
  background: #fff0b8;
  border: 1px solid #e1c55a;
  border-radius: 6px;
  padding: 0.1em 0.35em;
}

.app-header,
.control-panel,
.notice-panel,
.live-section,
.canvas-header,
.grareco-canvas,
footer {
  width: min(1480px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px;
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 800;
}

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

h1 {
  margin-bottom: 0.3rem;
  font-size: clamp(1.7rem, 2.6vw, 3rem);
  line-height: 1.12;
}

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

.status-card {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 130px;
  justify-content: center;
  padding: 0.8rem 1rem;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  font-weight: 900;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #b5b5b5;
  box-shadow: 0 0 0 4px rgba(0,0,0,0.05);
}

.dot.active {
  background: #35c86d;
}

.dot.busy {
  background: #f5a623;
}

.control-panel {
  margin-top: 28px;
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) repeat(4, minmax(150px, 0.8fr));
  gap: 16px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field.wide {
  min-width: 240px;
}

label {
  font-weight: 900;
  font-size: 0.9rem;
}

input,
select,
textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  color: var(--ink);
  padding: 0.78rem 0.9rem;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  box-shadow: 0 0 0 4px rgba(255, 214, 102, 0.35);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button-row.full {
  grid-column: 1 / -1;
}

.button-row.compact button {
  padding: 0.55rem 0.8rem;
  font-size: 0.88rem;
}

.notice-panel {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.notice-panel > div {
  padding: 16px 18px;
  background: #fff7d5;
  border: 2px dashed #9b7b00;
  border-radius: 18px;
}

.live-section {
  margin-top: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 20px;
}

.transcript-box,
.summary-box {
  padding: 20px;
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

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

.section-title h2 {
  margin-bottom: 0;
  font-size: clamp(1.08rem, 1vw, 1.32rem);
}

.mini-title {
  margin-top: 16px;
}

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

.summary-box textarea {
  min-height: 130px;
}

.interim {
  min-height: 1.8em;
  margin-bottom: 8px;
  color: #3267a8;
  font-weight: 800;
}

.memo-box {
  min-height: 92px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #eef6ff;
  padding: 14px;
  white-space: pre-wrap;
}

.canvas-header {
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  background: var(--paper);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.canvas-header h2 {
  margin-bottom: 0.2rem;
  font-size: clamp(1.35rem, 1.8vw, 2rem);
}

.canvas-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.grareco-canvas {
  margin-top: 24px;
  margin-bottom: 34px;
  padding: clamp(16px, 2.2vw, 28px);
  background: rgba(255, 253, 247, 0.94);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  overflow: visible;
}

.grareco-canvas.flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: clamp(16px, 2vw, 26px);
  align-items: stretch;
}

.grareco-canvas.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas:
    "purpose issues causes"
    "solutions decisions todos";
  gap: clamp(16px, 2vw, 26px);
}

.card {
  --accent: #f6edb6;
  --accent-border: rgba(0, 0, 0, 0.14);
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  min-height: clamp(170px, 16vw, 230px);
  height: auto;
  padding: clamp(16px, 1.7vw, 24px);
  border: 3px solid var(--line);
  border-radius: 22px;
  background: var(--accent);
  box-shadow: 6px 6px 0 var(--line);
  outline: none;
  overflow: visible;
  writing-mode: horizontal-tb !important;
  word-break: normal;
  overflow-wrap: anywhere;
}

.card::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1.5px dashed var(--accent-border);
  border-radius: 16px;
  pointer-events: none;
}

.grareco-canvas.flow .card:not(:last-child)::after {
  content: "→";
  position: absolute;
  top: 50%;
  right: -22px;
  transform: translateY(-50%);
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--line);
  z-index: 2;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}

.card-icon {
  flex: 0 0 auto;
  font-size: clamp(1.45rem, 1.8vw, 2rem);
}

.card h3 {
  margin: 0;
  font-size: var(--card-title-size);
  line-height: 1.25;
}

.card ul {
  margin: 0;
  padding-left: 1.25rem;
  font-size: var(--card-text-size);
  line-height: 1.55;
  min-width: 0;
}

.card li {
  margin: 0.32em 0;
  padding-left: 0.12em;
}

.card.dense {
  --card-text-size: clamp(0.78rem, 0.45vw + 0.68rem, 0.92rem);
  --card-title-size: clamp(0.98rem, 0.55vw + 0.78rem, 1.12rem);
}

.card.very-dense {
  --card-text-size: clamp(0.7rem, 0.35vw + 0.62rem, 0.82rem);
  --card-title-size: clamp(0.9rem, 0.45vw + 0.75rem, 1rem);
}

.card.large-text {
  --card-text-size: clamp(1rem, 0.75vw + 0.84rem, 1.22rem);
  --card-title-size: clamp(1.16rem, 0.85vw + 0.9rem, 1.38rem);
}

.card.compact-text {
  --card-text-size: clamp(0.74rem, 0.4vw + 0.66rem, 0.9rem);
  --card-title-size: clamp(0.92rem, 0.5vw + 0.76rem, 1.05rem);
}

.purpose { --accent: #fff4b8; --accent-border: #d4bd4a; grid-area: purpose; }
.issue { --accent: #ffd8d5; --accent-border: #d28e88; grid-area: issues; }
.cause { --accent: #ddeaff; --accent-border: #8aa5d0; grid-area: causes; }
.solution { --accent: #dcf5df; --accent-border: #77aa80; grid-area: solutions; }
.decision { --accent: #eadcff; --accent-border: #aa8fd3; grid-area: decisions; }
.todo { --accent: #ffeccd; --accent-border: #ce9c45; grid-area: todos; }

footer {
  color: var(--muted);
  padding-bottom: 28px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(420px, calc(100% - 40px));
  padding: 14px 18px;
  background: #222222;
  color: #ffffff;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.2);
  font-weight: 800;
}

@media (max-width: 1180px) {
  .control-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .live-section,
  .notice-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-header,
  .canvas-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .grareco-canvas.board {
    grid-template-columns: 1fr;
    grid-template-areas:
      "purpose"
      "issues"
      "causes"
      "solutions"
      "decisions"
      "todos";
  }

  .grareco-canvas.flow .card::after {
    display: none;
  }
}

@media (max-width: 640px) {
  .app-header,
  .control-panel,
  .notice-panel,
  .live-section,
  .canvas-header,
  .grareco-canvas,
  footer {
    width: min(100% - 18px, 1480px);
  }

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

  .live-section {
    grid-template-columns: 1fr;
  }

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

@media print {
  body {
    background: #ffffff;
  }

  .app-header,
  .control-panel,
  .notice-panel,
  .live-section,
  footer,
  .canvas-header .button-row {
    display: none !important;
  }

  .canvas-header,
  .grareco-canvas {
    width: 100%;
    margin: 0 0 16px;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .grareco-canvas.flow,
  .grareco-canvas.board {
    grid-template-columns: repeat(2, 1fr);
  }

  .grareco-canvas.flow .card::after {
    display: none;
  }
}
