/* myrec — design tokens & components. Warm, editorial, quiet. */

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f3f0ec;
  --surface-3: #ece8e2;
  --text: #1c1a17;
  --muted: #6f6a63;
  --faint: #9b958c;
  --border: #e6e2dc;
  --border-strong: #d6d1c9;
  --accent: #c2603f;
  --accent-soft: #f2ded6;
  --accent-ink: #ffffff;
  --ok: #3f7d5a;
  --warn: #a86a1f;
  --err: #b3261e;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-1: 0 1px 2px rgba(28, 26, 23, 0.06);
  --shadow-2: 0 1px 2px rgba(28, 26, 23, 0.06), 0 10px 30px -16px rgba(28, 26, 23, 0.24);
  --sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard Variable", Pretendard,
    "Noto Sans KR", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --measure: 66ch;
}

:root[data-theme="dark"] {
  --bg: #141311;
  --surface: #1c1b18;
  --surface-2: #232120;
  --surface-3: #2b2926;
  --text: #ece8e3;
  --muted: #9b958c;
  --faint: #6f6a63;
  --border: #2e2c28;
  --border-strong: #3a3733;
  --accent: #d9784f;
  --accent-soft: #3a241c;
  --accent-ink: #1a1310;
  --ok: #6fbf8f;
  --warn: #d9a05b;
  --err: #f2836f;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 34px -18px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ---------- chrome ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  overflow: hidden;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-size: 16px;
}
.brand > span:first-of-type {
  flex: none;
}
.brand img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: block;
}
.brand .sub {
  color: var(--faint);
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0;
}

.topbar .spacer {
  flex: 1;
}

.tabs {
  position: sticky;
  top: 45px;
  z-index: 15;
  display: flex;
  gap: 2px;
  padding: 0 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  padding: 11px 13px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 16px 96px;
}

/* ---------- primitives ---------- */
.btn {
  appearance: none;
  font: inherit;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, black);
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-icon {
  padding: 8px;
}
.btn-sm {
  font-size: 13px;
  padding: 5px 9px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}
.chip-mono {
  font-family: var(--mono);
  font-size: 11px;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ---------- forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field > label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
input,
select,
textarea {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  width: 100%;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -1px;
  border-color: var(--accent);
}
textarea {
  resize: vertical;
  min-height: 76px;
  line-height: 1.5;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.toolbar .field {
  min-width: 140px;
}
.toolbar .grow {
  flex: 1;
}

/* ---------- section head ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 4px 0 12px;
}
.section-head h2 {
  font-size: 15px;
  margin: 0;
  letter-spacing: -0.01em;
}
.section-head .count {
  color: var(--faint);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* ---------- session list ---------- */
.session-list {
  display: grid;
  gap: 10px;
}
.session-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.06s ease;
}
.session-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2);
}
.session-card:active {
  transform: translateY(1px);
}
.session-card .row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.session-card .time {
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  letter-spacing: -0.01em;
}
.session-card .dur {
  color: var(--faint);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.session-card .row1 .spacer {
  flex: 1;
}
.session-card .summary {
  color: var(--muted);
  font-size: 13.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.session-card .summary.is-empty {
  color: var(--faint);
  font-style: italic;
}
.session-card .meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 9px;
}

/* ---------- detail ---------- */
.detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.detail-head .title {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin: 0 0 6px;
  overflow-wrap: anywhere;
}
.detail-head .facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  margin-bottom: 14px;
}
.panel h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
}
.panel p {
  margin: 0;
  white-space: pre-wrap;
}
.panel ul {
  margin: 8px 0 0;
  padding-left: 18px;
}
.panel li {
  margin: 3px 0;
}

/* transcript */
.transcript {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--border);
}
.seg {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
}
.seg:hover {
  background: var(--surface-2);
}
.seg.is-target {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.seg .rail {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
  user-select: none;
}
.seg .rail .spk {
  display: block;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11px;
  margin-top: 2px;
}
.seg .body {
  min-width: 0;
  max-width: var(--measure);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.seg .low {
  color: var(--faint);
  font-size: 11px;
  margin-top: 4px;
  font-family: var(--mono);
}
.seg textarea {
  min-height: 60px;
  font-size: 14.5px;
}
.seg .edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 7px;
}

.seg .rail .rail-edit {
  font-size: 11px;
  padding: 2px 7px;
  margin-top: 7px;
  color: var(--faint);
}
.seg:hover .rail .rail-edit {
  color: var(--accent);
}
.seg.is-selected {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

/* search results */
.hits {
  display: grid;
  gap: 10px;
}
.hit {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}
.hit:hover {
  border-color: var(--border-strong);
}
.hit .hit-head {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 5px;
}
.hit .hit-time {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
}
.hit mark {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 2px;
}

/* ---------- states ---------- */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty .big {
  font-size: 30px;
  margin-bottom: 10px;
  opacity: 0.6;
}
.empty .hint {
  font-size: 13px;
  color: var(--faint);
  margin-top: 6px;
}

.error-box {
  border: 1px solid color-mix(in srgb, var(--err) 40%, var(--border));
  background: color-mix(in srgb, var(--err) 8%, var(--surface));
  color: var(--text);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.error-box .code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--err);
  margin-bottom: 4px;
}

.skeleton {
  height: 68px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

.busy {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: var(--bg);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 50;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.banner {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 14px;
}

/* ---------- responsive ---------- */
@media (min-width: 760px) {
  main {
    padding: 24px 24px 120px;
  }
  .seg {
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 18px;
    padding: 12px 18px;
  }
  .toolbar .field {
    min-width: 160px;
  }
}

@media (max-width: 560px) {
  .brand .sub {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .topbar,
  .tabs,
  .detail-actions,
  .toolbar {
    display: none;
  }
}
