/* Hallmark · macrostructure: Workbench · theme: Cobalt · tone: utilitarian · anchor hue: cobalt · enrichment: none · nav: N9 · footer: Ft2 · contrast: pass (40–41) · slop: pass (42–45) · honest: pass (46) · chrome: pass (47) · tokens: pass (48) · responsive: pass (49) · icons: pass (30) · mobile: pass (34, 49, 50–57) */
/* Hallmark · pre-emit critique: P5 H5 E5 S5 R5 V5 */
@import url("/tokens.css?v=3");

* { box-sizing: border-box; }

html {
  min-width: 320px;
  overflow-x: clip;
  background: var(--surface);
  font-family: var(--font-sans);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: clip;
  background: var(--surface);
}

button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; white-space: nowrap; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
button:not(:disabled):active { box-shadow: inset 0 0 0 1px var(--accent); }

.shell {
  width: min(100%, var(--content));
  min-height: 100dvh;
  margin: 0 auto;
  padding: var(--space-5);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--space-6);
}

.topbar {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--space-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -.04em;
}

.brand strong {
  display: block;
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 15px;
  letter-spacing: -.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small, .quiet { color: var(--ink-muted); }

.top-actions { display: flex; align-items: center; gap: var(--space-2); }
.top-actions button, .candidate-actions button, .footer > * { line-height: 1; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.text-button, .icon-button {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
}

.text-button {
  min-height: 40px;
  padding: 0 var(--space-2);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
}

.text-button:hover, .text-button:focus-visible { color: var(--accent); text-decoration-color: currentColor; }

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.workspace {
  align-self: start;
  display: grid;
  grid-template-columns: minmax(280px, .9fr) minmax(360px, 1.35fr);
  gap: var(--space-6);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.composer { padding: var(--space-6); }
.results { min-height: 480px; padding: var(--space-6); }

h1, h2, p { margin-top: 0; }
h1, h2 { min-width: 0; overflow-wrap: anywhere; color: var(--ink-strong); letter-spacing: -.025em; }
h1 { margin-bottom: var(--space-2); font-size: clamp(24px, 3vw, 34px); line-height: 1.1; }
h2 { margin-bottom: var(--space-5); font-size: 20px; }

.lede {
  margin-bottom: var(--space-6);
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.55;
}

.field { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.field label, .field-label { color: var(--ink-strong); font-size: 13px; font-weight: 650; }
.field-note { color: var(--ink-muted); font-size: 12px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: 0;
  background: var(--panel);
  color: var(--ink-strong);
  outline: 2px solid transparent;
  outline-offset: 2px;
}

input, select { min-height: 46px; padding: 0 var(--space-3); }
textarea { min-height: 160px; padding: var(--space-3); resize: vertical; line-height: 1.55; }
input:hover, select:hover, textarea:hover { border-color: var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; background: var(--panel-soft); }

.textarea-wrap { position: relative; }
.textarea-wrap textarea { padding-bottom: 48px; }
.paste-button {
  position: absolute;
  right: 8px;
  bottom: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
  padding: 0 12px;
}

.primary, .secondary, .danger-button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

.primary { width: 100%; background: var(--accent); color: var(--on-accent); }
.primary:hover { background: var(--accent-hover); }
.secondary { background: var(--panel); border-color: var(--line-strong); color: var(--ink-strong); }
.danger-button { background: var(--danger-soft); color: var(--danger); }
.secondary:hover, .paste-button:hover, .icon-button:hover { border-color: var(--accent); background: var(--panel-soft); }
.danger-button:hover { border-color: var(--danger); }
button:disabled { cursor: not-allowed; opacity: .55; }

.placeholder {
  min-height: 388px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  text-align: center;
  padding: var(--space-8);
}

.placeholder-symbol {
  width: 42px;
  height: 42px;
  margin: 0 auto var(--space-4);
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: var(--accent);
  transform: rotate(-3deg);
}

.notice {
  margin-bottom: var(--space-4);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  line-height: 1.5;
}

.notice.warning { border-left-color: var(--warning); background: var(--warning-soft); color: var(--warning); }
.notice.danger { border-left-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

.candidate-list { display: grid; gap: var(--space-4); }
.candidate {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--panel);
}

.candidate-main { padding: var(--space-4); }
.candidate-index { color: var(--ink-muted); font-family: var(--font-mono); font-size: 11px; }
.candidate-text { min-height: 48px; margin: var(--space-2) 0 var(--space-4); color: var(--ink-strong); line-height: 1.55; white-space: pre-wrap; }
.candidate-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.copy-button { min-width: 88px; }

.rating { display: flex; gap: var(--space-1); }
.star {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--line-strong);
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}
.star:hover { color: var(--rating); }
.star.active { color: var(--rating); }

.correction {
  display: none;
  padding: 0 var(--space-4) var(--space-4);
}
.correction.visible { display: grid; gap: var(--space-2); }
.correction textarea { min-height: 76px; }
.correction .secondary { justify-self: end; min-height: 38px; }

.auth-layout {
  width: min(100%, 460px);
  align-self: center;
  justify-self: center;
}
.auth-panel { padding: clamp(24px, 6vw, 40px); }
.auth-panel .primary { margin-top: var(--space-2); }
.auth-panel > .secondary { width: 100%; margin-top: var(--space-3); }
input[type="file"] { min-height: auto; padding: var(--space-3); }

.device-list { display: grid; gap: var(--space-3); }
.device-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-4);
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: var(--space-4) 0;
}
.device-row:last-child { border-bottom: 0; }
.device-meta strong { color: var(--ink-strong); }
.device-meta small { display: block; margin-top: 4px; color: var(--ink-muted); }

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border-top: 1px solid var(--line);
  padding-top: var(--space-4);
  color: var(--ink-muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(var(--space-6), env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  max-width: calc(100vw - 32px);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--ink-strong);
  color: var(--panel);
  box-shadow: var(--shadow);
  padding: var(--space-3) var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

.hidden { display: none !important; }
.busy-label::after { content: ""; display: inline-block; width: 1.2em; animation: dots 1s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75%, 100% { content: "..."; } }

@media (max-width: 760px) {
  .shell { padding: var(--space-4); gap: var(--space-4); }
  .workspace { grid-template-columns: 1fr; gap: var(--space-4); }
  .composer, .results { padding: var(--space-4); }
  .results { min-height: auto; }
  .field-row { grid-template-columns: 1fr; }
  .placeholder { min-height: 240px; }
  .candidate-actions { align-items: flex-start; flex-direction: column; }
  .copy-button { width: 100%; }
  .footer { align-items: flex-start; flex-direction: column; gap: var(--space-1); }
}

@media (max-width: 380px) {
  .brand small, .top-actions .status-dot { display: none; }
  .topbar { gap: var(--space-2); }
  .top-actions { flex: 0 0 auto; gap: 0; }
  .top-actions .text-button { min-width: 36px; padding-inline: 4px; font-size: 13px; white-space: nowrap; }
  .shell { padding-inline: var(--space-3); }
  .composer, .results { padding: var(--space-4); border-radius: var(--radius-md); }
  .star { width: 32px; }
}

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