:root {
  --ink: #171717; --paper: #f5f0e7; --card: #ffffff; --brand: #ffe15c; --accent: #e84d32;
  --muted: #5c5650; --soft: #fbf8f2; --line: 2px solid var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.masthead { display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px max(16px, 5vw); background: var(--brand); border-bottom: 4px solid var(--ink); }
.brand { font-size: clamp(36px, 7vw, 64px); font-weight: 1000; letter-spacing: -0.06em; line-height: 1; }
.dot { color: var(--accent); }
.tag { font-weight: 800; }
small { font-weight: 800; letter-spacing: 2px; font-size: 12px; }
.access-open { background: var(--card); border: var(--line); border-radius: 999px; padding: 8px 14px;
  font-weight: 800; cursor: pointer; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eee; }
.pill[data-state="ready"] { background: #c9f2c7; }
.pill[data-state="locked"] { background: var(--brand); }
.pill[data-state="disabled"], .pill[data-state="unavailable"] { background: #f6c9c0; }

.tabs { display: flex; gap: 8px; max-width: 1100px; margin: 20px auto 0; padding: 0 16px; }
.tabs [role="tab"] { border: var(--line); border-radius: 10px 10px 0 0; background: transparent; padding: 10px 18px;
  font-weight: 900; cursor: pointer; border-bottom: none; }
.tabs [aria-selected="true"] { background: var(--card); }
main { max-width: 1100px; margin: 0 auto 32px; padding: 0 16px; }
#translate-view, #studio-view { background: var(--card); border: 3px solid var(--ink); border-radius: 0 16px 16px 16px;
  padding: 20px; box-shadow: 6px 6px 0 var(--ink); }

.langbar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: end; }
.slot { min-width: 0; }
.swap { border: var(--line); border-radius: 10px; cursor: pointer; height: 52px; width: 52px; font-size: 22px; font-weight: 900; background: var(--brand); }
.fav-toggle { width: 100%; text-align: left; border: 2px solid var(--ink); border-radius: 8px; background: var(--soft); padding: 8px 10px; font-weight: 800; cursor: pointer; margin-bottom: 6px; }
.fav-toggle[aria-pressed="true"] { background: var(--brand); }

.picker { position: relative; display: block; }
.picker-label { display: block; font-size: 12px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.picker-button { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 12px; border: var(--line); border-radius: 10px; background: var(--soft); cursor: pointer; text-align: left; }
.picker-value { display: flex; flex-wrap: wrap; column-gap: 8px; align-items: baseline; min-width: 0; font-weight: 800; }
.picker-value .native, .picker-list .native { color: var(--muted); font-weight: 500; }
.badge { font-size: 11px; font-weight: 800; background: #f6c9c0; border-radius: 6px; padding: 1px 6px; }
.picker-panel { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: min(380px, calc(100vw - 32px));
  background: var(--card); border: var(--line); border-radius: 12px; box-shadow: 5px 5px 0 var(--ink); padding: 8px; }
.langbar .slot:last-child .picker-panel { left: auto; right: 0; }
.picker-search { width: 100%; padding: 10px 12px; border: var(--line); border-radius: 8px; margin-bottom: 6px; }
.picker-list { list-style: none; margin: 0; padding: 0; max-height: min(360px, 55vh); overflow-y: auto; outline: none; }
.picker-list .group { font-size: 11px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); padding: 10px 8px 4px; }
.picker-list [role="option"] { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.picker-list [role="option"].active, .picker-list [role="option"]:hover { background: #fff3b0; }
.picker-list [aria-selected="true"] .name { font-weight: 900; }
.picker-list [aria-selected="true"] .name::before { content: "✓ "; }

.service { margin: 14px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--soft); border: 2px dashed var(--muted); font-weight: 600; }
.service:empty { display: none; }
.service button { margin-left: 6px; }
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.panel { display: flex; flex-direction: column; border: var(--line); border-radius: 12px; min-width: 0; background: var(--card); }
.panel.output { background: var(--soft); }
#source-text, .target-text { flex: 1; min-height: 220px; padding: 16px; font-size: 20px; line-height: 1.45; border: none; border-radius: 12px 12px 0 0; resize: vertical; background: transparent; overflow-wrap: anywhere; white-space: pre-wrap; }
#source-text:focus-visible, .target-text:focus-visible { outline-offset: -3px; }
.target-text:empty { min-height: 0; flex: 0; padding: 0; }
.target-state { margin: 0; padding: 16px; color: var(--muted); flex: 1; }
.target-state:empty { display: none; }
.target-state.error { color: #9b1c08; font-weight: 700; }
.panel-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; border-top: 2px solid #e6e0d6; }
.tool { border: 2px solid var(--ink); background: var(--card); border-radius: 8px; padding: 6px 12px; font-weight: 800; cursor: pointer; }
.count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
button:disabled { opacity: .45; cursor: not-allowed; }

.translate-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 18px; }
.primary { padding: 13px 26px; border: 3px solid var(--ink); border-radius: 10px; background: var(--brand); font-weight: 950;
  cursor: pointer; box-shadow: 4px 4px 0 var(--ink); }
.primary:not(:disabled):active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.status { min-height: 1.5em; font-weight: 700; margin: 14px 4px; }

.studio h2 { margin: 0 0 4px; }
.lead { margin-top: 0; color: var(--muted); }
.studio-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; }
.field select, .field input[type="password"], .field textarea { font-size: 16px; font-weight: 500; letter-spacing: 0; text-transform: none;
  padding: 12px; border: var(--line); border-radius: 10px; background: var(--soft); min-height: 52px; }
.field textarea { min-height: 90px; resize: vertical; margin-bottom: 4px; }
.field input[type="range"] { min-height: 52px; accent-color: var(--accent); }
.voice-note { margin: 16px 0; padding: 12px 14px; border-radius: 10px; background: var(--soft); border: 2px dashed var(--muted); }
.voice-note:empty { display: none; }
.voice-note.missing { background: #fff3b0; border-color: var(--ink); }
.studio-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.studio-actions button:not(.primary) { padding: 12px 18px; border: 3px solid var(--ink); border-radius: 10px; background: var(--card); font-weight: 900; cursor: pointer; }

dialog { border: 3px solid var(--ink); border-radius: 16px; padding: 24px; max-width: min(480px, calc(100vw - 32px)); box-shadow: 7px 7px 0 var(--ink); }
dialog::backdrop { background: rgb(23 23 23 / .45); }
dialog h2 { margin-top: 0; }
footer { text-align: center; padding: 24px 16px 32px; font-weight: 800; font-size: 13px; }

@media (max-width: 760px) {
  .panels, .studio-grid { grid-template-columns: 1fr; }
  #source-text, .target-text { min-height: 150px; font-size: 18px; }
  .langbar { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; }
  .swap { width: 44px; }
  .picker-value .native { display: none; }
  #translate-view, #studio-view { padding: 14px; box-shadow: 4px 4px 0 var(--ink); }
  .translate-row .primary { width: 100%; }
  .masthead { padding: 12px 16px; flex-wrap: wrap; row-gap: 8px; }
  .access-open { font-size: 14px; padding: 6px 10px; }
  .brand-block small, .tag { display: none; }
  .langbar .slot .picker-panel { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; width: auto; }
}
