/* ROBERIN sleep time calculator - The New workspace (20260717a)
 * Scope: .tn-stc-* only. Gates baked in: scheme-token dark flip (#8/#14), aligned rows (#11/#35),
 * field label separation (#34), no decorative left rail (#30), lining/tabular numerals (#31),
 * empty-state visual frame (#10/#15), reactive/no-calc-button (#17). */

.tn-stc-page {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  color: #1a1208;
  -webkit-text-fill-color: currentColor;
}

.tn-stc-page,
.tn-stc-page * {
  box-sizing: border-box;
}

.tn-stc-tool {
  --stc-ink: #1a1208;
  --stc-muted: #5a4a30;
  --stc-line: #b8a888;
  --stc-soft: #ddd4be;
  --stc-paper: #faf6ee;
  --stc-wash: #f5efdf;
  --stc-surface: rgba(255, 252, 244, 0.74);
  --stc-card: rgba(255, 252, 244, 0.5);
  --stc-accent: #3f5c8a;
  --stc-accent-soft: rgba(63, 92, 138, 0.14);
  --stc-good: #2f6d54;
  --stc-track: rgba(184, 168, 136, 0.22);
  --stc-wave: #8a7a58;
  --stc-btn-sec-bg: #ede6d4;
  --stc-btn-sec-hover: #dfd4bb;
  --stc-btn-sec-text: #1a1208;
  --stc-btn-pri-bg: #1a1208;
  --stc-btn-pri-hover: #3f5c8a;
  --stc-btn-pri-text: #faf6ee;
  --stc-num: "Times New Roman", Times, Georgia, "Noto Serif KR", serif;
  margin: 0 auto 18px;
  border-top: 2px solid var(--stc-ink);
  border-bottom: 1px solid var(--stc-line);
  background: linear-gradient(180deg, var(--stc-paper), var(--stc-wash));
  color: var(--stc-ink);
  -webkit-text-fill-color: var(--stc-ink);
}

.tn-stc-tool ul,
.tn-stc-tool ol,
.tn-stc-tool li,
.tn-stc-tool dd {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tn-stc-tool dl,
.tn-stc-tool dt,
.tn-stc-tool p {
  margin: 0;
  padding: 0;
}

.tn-stc-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 0;
  min-height: 420px;
}

.tn-stc-input,
.tn-stc-result {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  padding: 18px;
}

.tn-stc-input {
  border-right: 1px solid var(--stc-line);
}

.tn-stc-pane-label {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 26px;
  border-bottom: 1px solid var(--stc-ink);
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  font: 700 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tn-stc-fields {
  display: grid;
  gap: 13px;
}

/* Mode toggle (segmented, 2-up) */
.tn-stc-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--stc-line);
  background: var(--stc-surface);
}

.tn-stc-mode {
  display: grid;
  gap: 1px;
  min-height: 46px;
  align-content: center;
  padding: 6px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  text-align: center;
  cursor: pointer;
}

.tn-stc-mode + .tn-stc-mode {
  border-left: 1px solid var(--stc-line);
}

.tn-stc-mode strong {
  font: 700 13px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
}

.tn-stc-mode span {
  font: 500 11px/1.3 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tn-stc-mode.is-active {
  background: var(--stc-btn-pri-bg);
  color: var(--stc-btn-pri-text);
  -webkit-text-fill-color: var(--stc-btn-pri-text);
}

.tn-stc-mode:focus-visible {
  outline: 2px solid var(--stc-accent);
  outline-offset: -3px;
}

/* Fields */
.tn-stc-field {
  display: grid;
  gap: 5px;
  min-width: 0;
  margin: 0;
  border: 0;
  background: none;
  align-content: start;
}

.tn-stc-field-label {
  display: block;
  padding: 0;
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  font: 700 12px/1.3 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.02em;
}

.tn-stc-timebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.tn-stc-control {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--stc-line);
  background: var(--stc-surface);
}

.tn-stc-control input {
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--stc-ink);
  -webkit-text-fill-color: var(--stc-ink);
  font: 700 20px/1 var(--stc-num);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
  text-align: center;
  outline: 0;
  appearance: none;
  -webkit-appearance: none;
}

.tn-stc-control input::-webkit-outer-spin-button,
.tn-stc-control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tn-stc-control input[type="number"] { -moz-appearance: textfield; }
/* Force the time/latency inputs to share the control surface (ID specificity beats the global
 * dark-hardening rule `.entry-content [class*="tn-"] input {background:#21170f!important}` -> no inner shading) */
.tn-stc-page #stcHour,
.tn-stc-page #stcMinute,
.tn-stc-page #stcLatency,
.tn-stc-page #stcHour:focus,
.tn-stc-page #stcMinute:focus,
.tn-stc-page #stcLatency:focus {
  background: transparent !important;
  background-color: transparent !important;
}

.tn-stc-control input::placeholder {
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  opacity: 0.5;
}

/* Time control: HH : MM */
.tn-stc-time {
  justify-content: center;
  gap: 4px;
}

.tn-stc-time input { flex: 1 1 0; width: 100%; max-width: 68px; }

.tn-stc-time-colon {
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  font: 700 18px/1 var(--stc-num);
}

/* Latency control: number + unit */
.tn-stc-control--suffix { justify-content: space-between; padding-right: 0; }
.tn-stc-control--suffix input { flex: 1 1 auto; text-align: left; padding-left: 0; font-size: 17px; }

.tn-stc-control--suffix b {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  padding: 0 12px;
  border-left: 1px solid var(--stc-soft);
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
}

.tn-stc-control input:focus-visible {
  outline: 2px solid var(--stc-accent);
  outline-offset: -4px;
}

/* Quick chip ("지금") */
.tn-stc-chip {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--stc-line);
  border-radius: 0;
  background: var(--stc-btn-sec-bg);
  color: var(--stc-btn-sec-text);
  -webkit-text-fill-color: var(--stc-btn-sec-text);
  font: 700 13px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
  white-space: nowrap;
  cursor: pointer;
}

.tn-stc-chip:hover { background: var(--stc-btn-sec-hover); }
.tn-stc-chip:focus-visible { outline: 2px solid var(--stc-accent); outline-offset: 2px; }

.tn-stc-field-hint {
  display: block;
  min-height: 16px;
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  font: 500 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Command */
.tn-stc-command {
  display: grid;
  gap: 8px;
}

.tn-stc-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tn-stc-actions > button {
  display: grid;
  place-items: center;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--stc-line);
  border-radius: 0;
  background: var(--stc-btn-sec-bg);
  color: var(--stc-btn-sec-text);
  -webkit-text-fill-color: var(--stc-btn-sec-text);
  font: 700 13px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tn-stc-actions > button:hover { background: var(--stc-btn-sec-hover); }
.tn-stc-actions > button:focus-visible { outline: 2px solid var(--stc-accent); outline-offset: 2px; }

.tn-stc-actions > .tn-stc-primary {
  border-color: var(--stc-btn-pri-bg);
  background: var(--stc-btn-pri-bg);
  color: var(--stc-btn-pri-text);
  -webkit-text-fill-color: var(--stc-btn-pri-text);
}

.tn-stc-actions > .tn-stc-primary:hover {
  background: var(--stc-btn-pri-hover);
  border-color: var(--stc-btn-pri-hover);
}

.tn-stc-status {
  min-height: 18px;
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  font: 600 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tn-stc-status[data-state="error"] { color: #b3341a; -webkit-text-fill-color: #b3341a; }
.tn-stc-status[data-state="success"] { color: #2f6d54; -webkit-text-fill-color: #2f6d54; }

/* Result pane */
.tn-stc-headline {
  color: var(--stc-ink);
  -webkit-text-fill-color: var(--stc-ink);
  font: 600 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
}

.tn-stc-headline b {
  color: var(--stc-accent);
  -webkit-text-fill-color: var(--stc-accent);
  font-weight: 800;
}

/* Visual timeline (SVG hypnogram) */
.tn-stc-figure {
  display: grid;
  gap: 6px;
  padding: 14px 14px 12px;
  border: 1px solid var(--stc-line);
  background: var(--stc-surface);
}

.tn-stc-figure-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.tn-stc-figure-title {
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tn-stc-figure-legend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  font: 500 11px/1.3 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tn-stc-figure-legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--stc-good);
}

.tn-stc-figure svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.tn-stc-cycle-guide { stroke: var(--stc-soft); stroke-width: 1; stroke-dasharray: 2 3; }
.tn-stc-cycle-base { stroke: var(--stc-line); stroke-width: 1; }
.tn-stc-wave { fill: none; stroke: var(--stc-wave); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.tn-stc-dot { fill: var(--stc-track); stroke: var(--stc-line); stroke-width: 1; }
.tn-stc-dot.is-rec { fill: var(--stc-good); stroke: var(--stc-good); }
.tn-stc-tick { fill: var(--stc-muted); font: 700 10px var(--stc-num); font-variant-numeric: tabular-nums lining-nums; }
.tn-stc-tick.is-rec { fill: var(--stc-good); }
.tn-stc-anchor-label { fill: var(--stc-ink); font: 700 10px ui-monospace, monospace; }

/* Option cards */
.tn-stc-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tn-stc-option {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 11px 12px 12px;
  border: 1px solid var(--stc-soft);
  background: var(--stc-card);
}

.tn-stc-option.is-best {
  border-color: var(--stc-good);
  background: var(--stc-surface);
  box-shadow: inset 0 -2px 0 var(--stc-good);
}

.tn-stc-option-cycles {
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.02em;
}

.tn-stc-option-time {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--stc-ink);
  -webkit-text-fill-color: var(--stc-ink);
  font: 700 clamp(24px, 4.4vw, 30px)/1.05 var(--stc-num);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
  white-space: nowrap;
}

.tn-stc-option-ampm {
  font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
}

.tn-stc-option-dur {
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  font: 500 12px/1.3 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tn-stc-option-badge {
  position: absolute;
  top: 9px;
  right: 10px;
  padding: 1px 7px;
  border: 1px solid var(--stc-good);
  color: var(--stc-good);
  -webkit-text-fill-color: var(--stc-good);
  font: 700 10px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tn-stc-note {
  padding: 10px 12px;
  border: 1px solid var(--stc-soft);
  background: var(--stc-card);
  color: var(--stc-ink);
  -webkit-text-fill-color: var(--stc-ink);
  font: 500 12.5px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
}

.tn-stc-disclaimer {
  color: var(--stc-muted);
  -webkit-text-fill-color: var(--stc-muted);
  font: 500 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Mobile */
@media (max-width: 720px) {
  .tn-stc-grid { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .tn-stc-input { border-right: 0; border-bottom: 1px solid var(--stc-line); }
  .tn-stc-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 380px) {
  .tn-stc-options { grid-template-columns: minmax(0, 1fr); }
}

/* Dark / inverse / auto-dark (#8/#14) */
body:is([data-scheme="dark"], [data-scheme="inverse"], [data-scheme="auto"][data-d="dark"], [data-scheme="auto"][data-l="dark"]):not([data-scheme="light"]) .tn-stc-tool,
html[data-scheme="dark"] body:not([data-scheme="light"]) .tn-stc-tool,
html[data-scheme="inverse"] body:not([data-scheme="light"]) .tn-stc-tool {
  --stc-ink: #efe6d2;
  --stc-muted: #c3b492;
  --stc-line: #6f6047;
  --stc-soft: #574a37;
  --stc-paper: #241d12;
  --stc-wash: #241d12;
  --stc-surface: #322a1a;
  --stc-card: #2c2517;
  --stc-accent: #8fb0e6;
  --stc-accent-soft: rgba(143, 176, 230, 0.16);
  --stc-good: #74c4a0;
  --stc-track: rgba(120, 104, 74, 0.3);
  --stc-wave: #b6a67e;
  --stc-btn-sec-bg: #33291a;
  --stc-btn-sec-hover: #453720;
  --stc-btn-sec-text: #efe6d2;
  --stc-btn-pri-bg: #37507d;
  --stc-btn-pri-hover: #45618f;
  --stc-btn-pri-text: #eef3fb;
  color: var(--stc-ink);
  -webkit-text-fill-color: var(--stc-ink);
}

@media (prefers-color-scheme: dark) {
  body[data-scheme="auto"]:not([data-scheme="light"]) .tn-stc-tool {
    --stc-ink: #efe6d2;
    --stc-muted: #c3b492;
    --stc-line: #6f6047;
    --stc-soft: #574a37;
    --stc-paper: #241d12;
    --stc-wash: #241d12;
    --stc-surface: #322a1a;
    --stc-card: #2c2517;
    --stc-accent: #8fb0e6;
    --stc-accent-soft: rgba(143, 176, 230, 0.16);
    --stc-good: #74c4a0;
    --stc-track: rgba(120, 104, 74, 0.3);
    --stc-wave: #b6a67e;
    --stc-btn-sec-bg: #33291a;
    --stc-btn-sec-hover: #453720;
    --stc-btn-sec-text: #efe6d2;
    --stc-btn-pri-bg: #37507d;
    --stc-btn-pri-hover: #45618f;
    --stc-btn-pri-text: #eef3fb;
    color: var(--stc-ink);
    -webkit-text-fill-color: var(--stc-ink);
  }
}
