:root {
  --bg-1: #f3ede2;
  --bg-2: #dde7e9;
  --paper: #fbfaf6;
  --ink: #23313a;
  --line: #c7bdab;
  --accent: #0f5f66;
  --accent-warm: #a44a17;
  --danger: #a22020;
  --ok: #1f7a4e;
  --shadow: 0 16px 36px rgba(21, 33, 38, 0.14);
  --font-head: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  --font-body: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1100px 600px at -5% 0%, rgba(164, 74, 23, 0.13), transparent 60%),
    radial-gradient(1000px 540px at 105% 10%, rgba(15, 95, 102, 0.15), transparent 65%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
}

.app {
  width: min(1080px, 95vw);
  margin: 1.2rem auto 2.5rem;
  display: grid;
  gap: 1rem;
}

.hero,
.panel,
.year-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: var(--shadow);
}

.hero,
.panel {
  padding: 1rem 1.15rem;
}

.kicker {
  margin: 0;
  font-family: var(--font-head);
  color: var(--accent-warm);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
}

h1,
h2,
h3 {
  margin: 0.35rem 0 0.55rem;
  font-family: var(--font-head);
}

.subtitle {
  margin-top: -0.2rem;
  font-size: 1.05rem;
  color: #30444a;
}

.controls {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

label {
  display: grid;
  gap: 0.35rem;
}

input[type="text"],
input[type="number"],
textarea {
  font: inherit;
  border: 1px solid #bdb3a2;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: #fffefc;
  color: var(--ink);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 0.75rem;
}

.summary article {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.75rem;
  background: #fff;
}

.metric-label {
  margin: 0;
  color: #4c5f65;
}

.metric {
  margin: 0.35rem 0 0;
  font-size: 1.1rem;
}

.timeline {
  display: grid;
  gap: 0.85rem;
}

.spiral-head p {
  margin: 0;
  color: #42575d;
}

.spiral-tools {
  margin-top: 0.7rem;
  display: flex;
  gap: 0.6rem;
  align-items: end;
  flex-wrap: wrap;
}

.spiral-tools label {
  min-width: min(420px, 100%);
}

.topic-bank-wrap {
  margin-top: 0.8rem;
}

.topic-bank-wrap h3 {
  margin-bottom: 0.45rem;
}

.topic-bank {
  min-height: 56px;
  border: 1px dashed #8a9ba0;
  border-radius: 12px;
  background: #f6f9f9;
  padding: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid #56717a;
  border-radius: 999px;
  background: #edf4f5;
  color: #1f3c43;
  padding: 0.3rem 0.65rem;
  font-size: 0.86rem;
  cursor: grab;
  user-select: none;
}

.topic-chip:active {
  cursor: grabbing;
}

.topic-chip button {
  border: 0;
  border-radius: 50%;
  width: 1.1rem;
  height: 1.1rem;
  display: inline-grid;
  place-items: center;
  background: #7b3e25;
  color: #fff;
  padding: 0;
  font-size: 0.75rem;
}

.spiral-board {
  margin-top: 1rem;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(circle at center, rgba(15, 95, 102, 0.06), transparent 55%),
    linear-gradient(180deg, #fffefa, #f5f3ef);
  position: relative;
  overflow: hidden;
}

.year-orbit {
  position: absolute;
  border: 2px dashed #9ea9ab;
  border-radius: 50%;
  padding: 0.8rem 0.8rem 1.1rem;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 0.45rem;
  transition: background 120ms ease, border-color 120ms ease;
  touch-action: none;
}

.year-orbit h4 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 0.95rem;
}

.orbit-toolbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.orbit-move {
  font-size: 0.72rem;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  background: #405c61;
}

.year-orbit .dropzone-list {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  max-height: 64%;
  overflow: auto;
  padding: 0.2rem;
}

.orbit-resize {
  position: absolute;
  width: 16px;
  height: 16px;
  right: 10px;
  bottom: 10px;
  border-radius: 4px;
  background:
    linear-gradient(135deg, transparent 35%, #355055 35% 47%, transparent 47% 58%, #355055 58% 70%, transparent 70%);
  border: 1px solid #355055;
  cursor: nwse-resize;
  padding: 0;
}

.dropzone.active-drop {
  background: rgba(15, 95, 102, 0.1);
  border-color: #0f5f66;
}

.year-card {
  overflow: hidden;
}

.year-head {
  width: 100%;
  border: 0;
  background: linear-gradient(90deg, rgba(15, 95, 102, 0.15), rgba(164, 74, 23, 0.1));
  padding: 0.8rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.year-title {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  text-align: left;
}

.year-name {
  margin: 0;
  font-family: var(--font-head);
  font-size: 1.02rem;
}

.year-phase {
  font-size: 0.82rem;
  color: #42575d;
}

.status {
  font-size: 0.78rem;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  border: 1px solid #917763;
  background: #fff6ed;
  color: #794725;
}

.status.complete {
  border-color: #4f8f70;
  background: #eef8f2;
  color: #1f5c3e;
}

.year-content {
  padding: 0.9rem 1rem 1rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.75rem;
}

.year-content[hidden] {
  display: none;
}

.fields {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.confidence-wrap {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.confidence-value {
  min-width: 2.25rem;
  text-align: center;
  font-family: var(--font-head);
  color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

button,
.btn-alt {
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 0.52rem 0.85rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover,
.btn-alt:hover {
  filter: brightness(0.93);
}

.btn-alt {
  background: #655948;
}

.danger {
  background: var(--danger);
}

#import-json {
  display: none;
}

a {
  color: #004f8b;
}

@media (max-width: 860px) {
  .controls,
  .summary-grid,
  .fields {
    grid-template-columns: 1fr;
  }

  .spiral-board {
    min-height: 620px;
  }
}

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

  .app {
    width: 100%;
    margin: 0;
  }

  .actions {
    display: none;
  }

  .year-content[hidden] {
    display: grid;
  }
}
