:root {
  --bg: #14160f;
  --card: #22261c;
  --card-2: #2a2f22;
  --ink: #f4f1e8;
  --muted: #b7b4a6;
  --faint: #8d8b7c;
  --line: #3c4232;
  --amber: #e6a15a;
  --amber-ink: #1c140c;
  --green: #b7cf8d;
  --red: #e39b8c;
  --field: #171a13;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --serif: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: "Outfit", "Avenir Next", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.45;
  background:
    radial-gradient(1000px 480px at 8% -10%, rgba(230, 161, 90, 0.16), transparent 55%),
    radial-gradient(800px 420px at 100% 0%, rgba(183, 207, 141, 0.08), transparent 50%),
    var(--bg);
}

body.is-dragging { cursor: grabbing; user-select: none; }
body.menu-open { overflow: hidden; }

::selection { background: var(--amber); color: var(--amber-ink); }

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

button { cursor: pointer; }

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 6;
  background: var(--amber);
  color: var(--amber-ink);
  padding: 8px 12px;
  border-radius: 999px;
  text-decoration: none;
}

.skip:focus { top: 12px; }

.wrap {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.mark {
  margin: 0 0 6px;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.05rem, 4vw, 2.85rem);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 0.98;
  overflow-wrap: anywhere;
}

.lede {
  margin: 6px 0 0;
  max-width: 38rem;
  color: var(--muted);
}

.meta, .status {
  margin: 4px 0 0;
  color: var(--faint);
  font-size: 0.95rem;
}

.status { min-height: 1.4em; }

.desk {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 12px;
  margin-top: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.card:focus-within { border-color: #8d6a3b; }

.card.dragging {
  opacity: 0.72;
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.card-bar {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 8px 8px 0;
}

.titles { flex: 1; min-width: 0; padding-top: 6px; }

.kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}

.card h2 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 14px 14px;
  flex: 1;
}

.card[data-type="clock"] .card-body { justify-content: center; }
.card[data-type="countdown"] .card-body { justify-content: flex-end; }

.time {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.8rem, 5vw, 3.8rem);
  font-weight: 560;
  letter-spacing: -0.04em;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.zone, .host, .hint, .progress { margin: 0; color: var(--muted); }

.count { margin: 0; display: flex; align-items: baseline; gap: 8px; }

.count-num {
  font-family: var(--serif);
  font-size: clamp(2.7rem, 5vw, 3.6rem);
  font-weight: 560;
  letter-spacing: -0.04em;
  line-height: 0.9;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.count.is-today .count-num { color: var(--green); }

.count.is-past .count-num { color: var(--muted); }

.count-unit { color: var(--muted); font-size: 1rem; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
}

.grip { cursor: grab; touch-action: none; }

.icon-btn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.04); }

.btn, .choice {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 10px 16px;
}

.btn.primary {
  background: var(--amber);
  color: var(--amber-ink);
  border-color: transparent;
  font-weight: 600;
}

.btn.primary:hover { filter: brightness(1.05); }

.btn.tiny { padding: 6px 12px; border-radius: 999px; }

.text-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

input[type="text"],
input[type="url"],
input[type="date"],
textarea {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 1rem;
  color-scheme: dark;
}

textarea { min-height: 96px; resize: vertical; flex: 1; }

input[aria-invalid="true"] { border-color: var(--red); }

.todo-list, .link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.todo, .link-row, .add-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.todo input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--amber);
  flex: 0 0 auto;
}

.todo input[type="text"] { flex: 1 1 auto; width: auto; min-width: 0; }

.todo.done input[type="text"] {
  color: var(--faint);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.link-row a {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--field);
}

.link-row a:hover { outline: 1px solid var(--amber); }

.host { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.add-row input { flex: 1 1 8rem; width: auto; min-width: 0; }
form[data-link-form] { flex-wrap: wrap; }
form[data-link-form] input { flex: 1 1 9rem; }
form[data-link-form] .btn { width: auto; }
.link-row a { overflow-wrap: anywhere; }

.field-error { margin: 0; color: var(--red); min-height: 1.2em; font-size: 0.92rem; }

.empty, .loading {
  grid-column: 1 / -1;
  margin: 12px 0;
  padding: 36px 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
}

.empty .btn { margin: 8px 6px 0; }

.menu {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 10, 6, 0.62);
}

.menu[hidden], .toast[hidden] { display: none; }

.sheet {
  width: min(560px, 100%);
  max-height: min(92vh, 720px);
  overflow: auto;
  background: #1c2018;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sheet-bar h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 560;
  font-size: 1.6rem;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.choice {
  text-align: left;
  border-radius: 14px;
  background: var(--field);
  padding: 12px 14px;
}

.choice strong {
  display: block;
  font-family: var(--serif);
  font-weight: 560;
  font-size: 1.15rem;
}

.choice span { display: block; color: var(--muted); font-size: 0.92rem; margin-top: 2px; }

.choice:disabled { opacity: 0.45; cursor: not-allowed; }

.sheet-foot { margin: 12px 0 0; }

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(360px, calc(100% - 24px));
  padding: 10px 10px 10px 16px;
  border-radius: 999px;
  background: #2c311f;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.toast #undo { margin-left: auto; }

.noscript {
  width: min(1120px, calc(100% - 32px));
  margin: 16px auto;
  color: var(--red);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .wrap { width: min(1120px, calc(100% - 24px)); padding-top: 16px; }
  form[data-link-form] .btn { width: 100%; }
  .top { flex-direction: column; align-items: stretch; }
  .btn.primary { width: 100%; }
  .choices { grid-template-columns: 1fr; }
  .menu { place-items: end center; padding: 0; }
  .sheet { border-radius: 20px 20px 0 0; padding-bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
