:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #68758d;
  --line: #cad4e5;
  --paper: #eef3fb;
  --panel: #ffffff;
  --accent: #ff4f8b;
  --blue: #27a7ff;
  --mint: #33d6a6;
  --gold: #ffc845;
  --accent-ink: #ffffff;
  --shadow: 0 18px 45px rgba(23, 32, 51, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 79, 139, 0.24), transparent 26rem),
    radial-gradient(circle at 92% 4%, rgba(39, 167, 255, 0.22), transparent 24rem),
    linear-gradient(135deg, rgba(255, 200, 69, 0.15) 0 14px, transparent 14px 28px),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover,
.import-button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

.workspace,
.sidebar {
  min-width: 0;
}

.topbar,
.timeline-panel,
.event-form,
.event-list-wrap {
  background: var(--panel);
  border: 2px solid #172033;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  margin-bottom: 16px;
  background:
    linear-gradient(90deg, rgba(255, 79, 139, 0.12), rgba(39, 167, 255, 0.12)),
    #fff;
  box-shadow: 7px 7px 0 #172033;
}

.title-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.site-logo {
  flex: 0 0 auto;
  width: clamp(88px, 12vw, 150px);
  height: auto;
  display: block;
  filter: drop-shadow(4px 4px 0 rgba(23, 32, 51, 0.22));
}

.eyebrow {
  margin: 0 0 5px;
  color: #486178;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 100%;
  font-size: clamp(1.6rem, 3vw, 2.65rem);
  line-height: 1.05;
  outline: none;
  text-shadow: 2px 2px 0 rgba(255, 200, 69, 0.55);
}

h1:focus {
  box-shadow: inset 0 -2px 0 var(--accent);
}

h2 {
  font-size: 1rem;
}

.topbar-actions,
.zoom-group,
.date-window,
.field-row,
.form-head,
.list-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-actions button,
.import-button,
.form-head button,
.zoom-group button {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 13px;
  font-weight: 700;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.import-button {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.import-button input {
  display: none;
}

.timeline-panel {
  overflow: hidden;
  box-shadow: 7px 7px 0 rgba(255, 79, 139, 0.8);
}

.chart-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-bottom: 2px solid #172033;
  background: #fbfcff;
}

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

input,
textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(47, 128, 237, 0.16);
}

textarea {
  resize: vertical;
}

.zoom-group {
  flex: 0 0 210px;
}

.zoom-group button {
  width: 38px;
  padding: 0;
}

.zoom-group input {
  padding: 0;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--ink);
  white-space: nowrap;
}

.toggle-control input {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--accent);
}

.ghost-action {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 12px;
  font-weight: 800;
  background: #fff7d9;
}

.timeline-scroll {
  min-height: 520px;
  overflow: auto;
  background:
    linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92)) padding-box,
    linear-gradient(90deg, rgba(39, 167, 255, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(255, 79, 139, 0.10) 1px, transparent 1px);
  background-size: auto, 32px 32px, 32px 32px;
}

#timelineSvg {
  display: block;
  min-width: 100%;
  min-height: 520px;
}

.sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
}

.event-form {
  display: grid;
  gap: 14px;
  padding: 16px;
  box-shadow: 7px 7px 0 rgba(39, 167, 255, 0.75);
}

.form-head,
.list-head {
  justify-content: space-between;
}

.field-row {
  align-items: start;
}

.field-row label {
  flex: 1;
  min-width: 0;
}

.primary-action {
  min-height: 44px;
  border: 2px solid #172033;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), #ff8a4c);
  color: var(--accent-ink);
  font-weight: 800;
  box-shadow: 4px 4px 0 #172033;
}

.event-list-wrap {
  min-height: 0;
  padding: 14px;
  box-shadow: 7px 7px 0 rgba(51, 214, 166, 0.75);
}

.list-head {
  margin-bottom: 10px;
}

#eventCount {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid #172033;
  background: var(--gold);
  color: #172033;
  font-weight: 800;
}

.event-list {
  display: grid;
  gap: 9px;
  max-height: calc(100vh - 505px);
  min-height: 180px;
  overflow: auto;
}

.event-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.event-card:hover {
  border-color: #172033;
  box-shadow: 4px 4px 0 rgba(23, 32, 51, 0.18);
  transform: translateY(-1px);
}

.event-card-main {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  border: 0;
  padding: 0;
  text-align: left;
}

.event-card-main strong,
.event-card-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-card-main small {
  color: var(--muted);
  font-size: 0.78rem;
}

.swatch {
  width: 12px;
  height: 36px;
  border-radius: 999px;
}

.delete-event {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  color: #b7194b;
  font-size: 1.25rem;
  line-height: 1;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 170px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.axis-label {
  fill: #42556e;
  font-size: 12px;
  font-weight: 700;
}

.event-label {
  fill: #1f2933;
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
}

.range-label {
  fill: #ffffff;
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
}

.event-sub {
  fill: #65758b;
  font-size: 11px;
  pointer-events: none;
}

.timeline-event {
  cursor: pointer;
}

.selected-event .event-label,
.selected-event .event-sub {
  fill: #b7194b;
}

.selected-event circle,
.selected-event rect {
  stroke: #ffc845;
  stroke-width: 4;
}

.callout-line {
  stroke: #8c99ab;
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

.today-line {
  stroke: #ff4f8b;
  stroke-width: 2;
  stroke-dasharray: 5 5;
}

.gap-bar {
  stroke: #172033;
  stroke-width: 3;
  stroke-linecap: round;
}

.gap-end {
  stroke: #172033;
  stroke-width: 2;
}

.gap-label {
  fill: #39495d;
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.compare-line {
  fill: none;
  stroke: #ff4f8b;
  stroke-width: 3;
  stroke-linecap: round;
  pointer-events: none;
}

.compare-ring {
  fill: none;
  stroke: #ffc845;
  stroke-width: 4;
  pointer-events: none;
}

.compare-pill {
  fill: #172033;
  stroke: #ffc845;
  stroke-width: 2;
  pointer-events: none;
}

.compare-label {
  fill: #ffffff;
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
}

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

  .event-list {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .chart-toolbar,
  .field-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .date-window,
  .zoom-group,
  .toggle-control,
  .ghost-action {
    width: 100%;
  }

  .topbar-actions > *,
  .date-window label {
    flex: 1;
  }
}
