:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --line: rgba(0,0,0,0.08);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0,113,227,0.10);
  --ok: #34c759;
  --warn: #ff9f0a;
  --err: #ff3b30;
  --shadow: 0 2px 10px rgba(0,0,0,0.04), 0 12px 32px rgba(0,0,0,0.06);
  --radius: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter, "Segoe UI", Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --line: rgba(255,255,255,0.10);
    --accent: #2997ff;
    --accent-hover: #3aa0ff;
    --accent-soft: rgba(41,151,255,0.16);
    --shadow: 0 2px 10px rgba(0,0,0,0.3), 0 12px 32px rgba(0,0,0,0.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.01em;
  padding-bottom: 120px;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--text-2); font-size: 14px; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.brand { font-weight: 600; font-size: 17px; letter-spacing: -0.02em; }
.nav-note { font-size: 12px; color: var(--text-2); }

/* Hero */
.hero { text-align: center; padding: 72px 0 40px; }
.hero h1 {
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.07;
  margin: 0 0 16px;
}
.hero p {
  color: var(--text-2);
  font-size: clamp(17px, 2vw, 21px);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.4;
}

/* Cards */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  text-align: left;
  display: flex; flex-direction: column; gap: 6px;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.06), 0 18px 40px rgba(0,0,0,0.09); }
.card:active { transform: translateY(0); }
.card.source { cursor: default; }
.card.source:active { transform: translateY(-2px); }
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--accent);
  border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 14px;
  transition: background .15s, border-color .15s, color .15s;
}
.pill:hover { background: var(--accent-soft); border-color: var(--accent); }
.pill:active { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.card.filled { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.card.drag { border-color: var(--accent); background: var(--accent-soft); }
.card-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font-weight: 700; font-size: 20px; margin-bottom: 10px;
}
.card-icon.out { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.card-title { font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }
.card-sub { color: var(--text-2); font-size: 14px; }
.card.filled .card-sub { color: var(--text); }

/* Time bar */
.timebar {
  margin-top: 36px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 14px 18px;
}
.timebar-label { font-weight: 600; font-size: 15px; color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 500; font-size: 15px;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.custom { display: flex; gap: 8px; align-items: center; }
.custom input {
  width: 170px; height: 38px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); padding: 0 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.custom input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.btn {
  border: 0; border-radius: 999px; padding: 10px 20px;
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
  transition: background .15s, transform .1s, opacity .15s;
}
.btn.primary { background: var(--accent); color: #fff; padding: 13px 28px; font-size: 17px; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { transform: scale(0.98); }
.btn.primary:disabled { opacity: .35; cursor: default; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); height: 38px; padding: 0 16px; }
.btn.ghost:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; margin-left: auto; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 42px; height: 26px; border-radius: 999px; background: #d1d1d6; position: relative;
  transition: background .2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25);
  transition: transform .2s;
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch-text { font-size: 15px; color: var(--text-2); font-weight: 500; }

/* Table */
.table-wrap {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: visible;
}
table.pairs { width: 100%; border-collapse: collapse; }
.pairs th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-2); padding: 16px 16px 12px; border-bottom: 1px solid var(--line);
}
.pairs td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.pairs tr:last-child td { border-bottom: 0; }
.pairs tr.done td { background: color-mix(in srgb, var(--ok) 6%, transparent); }
.c-idx { width: 44px; color: var(--text-2); }
.c-time { width: 190px; }
.c-status { width: 160px; }
.fname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; display: block; }
.fdur { color: var(--text-2); font-size: 13px; }
.table-wrap .muted { padding: 12px 16px 16px; margin: 0; }

/* Combobox */
.combo { position: relative; }
.combo input {
  width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); padding: 0 36px 0 12px; outline: none;
  font-variant-numeric: tabular-nums; font-weight: 500;
  transition: border-color .15s, box-shadow .15s;
}
.combo input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.combo.invalid input { border-color: var(--err); }
.combo.warn input { border-color: var(--warn); }
.combo .caret {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; pointer-events: none; color: var(--text-2);
}
.combo .menu {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; min-width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.14); padding: 6px; display: none;
}
.combo.open .menu { display: block; }
.combo .menu button {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  padding: 8px 10px; border-radius: 8px; font-size: 15px; font-variant-numeric: tabular-nums;
}
.combo .menu button:hover, .combo .menu button.hl { background: var(--accent-soft); color: var(--accent); }
.combo .hint { font-size: 12px; color: var(--text-2); margin-top: 4px; min-height: 14px; }

/* Status */
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); font-weight: 500; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #c7c7cc; }
.status.working .dot { background: var(--accent); animation: pulse 1s infinite; }
.status.done { color: var(--ok); } .status.done .dot { background: var(--ok); }
.status.error { color: var(--err); } .status.error .dot { background: var(--err); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* Empty */
.empty { text-align: center; padding: 56px 0; color: var(--text-2); }

/* Action bar */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border-top: 1px solid var(--line);
}
.actionbar-inner { display: flex; align-items: center; gap: 24px; height: 84px; }
.progress { flex: 1; }
.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .25s ease; }
.progress-text { font-size: 13px; color: var(--text-2); margin-top: 8px; }

@media (max-width: 760px) {
  .cards { grid-template-columns: 1fr; }
  .hero { padding: 48px 0 28px; }
  .c-time { width: 150px; }
  .fname { max-width: 150px; }
  .c-status { width: 110px; }
  .switch { margin-left: 0; }
  .actionbar-inner { gap: 14px; }
}
