/* 社内翻訳 — 「校正紙」の見た目。紙の地、墨の文字、朱は操作、藍は訳文。
 * 書体は fonts.css（frutiger プリセット）の --font-* だけを使う。 */

:root {
  --paper: #f5f1e8;
  --sheet: #fffdf8;
  --rule: #e0d9c9;
  --rule-strong: #cbbfa6;
  --ink: #1d2126;
  --ink-soft: #5d6168;
  --shu: #c8402a;          /* 朱: 実行・進捗 */
  --shu-deep: #a3321f;
  --shu-wash: #fbe9e4;
  --ai: #1f3a5f;           /* 藍: 訳文 */
  --ai-wash: #eaf0f7;
  --ok: #2f7d4f;
  --off: #a9a59b;
  --radius: 6px;
  --shadow: 0 1px 0 rgba(29, 33, 38, .04), 0 6px 18px -12px rgba(29, 33, 38, .25);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16181b;
    --sheet: #1e2125;
    --rule: #30343a;
    --rule-strong: #454a52;
    --ink: #e9e6df;
    --ink-soft: #b6b5ae;
    --shu: #e3644c;
    --shu-deep: #f07a63;
    --shu-wash: #3a221d;
    --ai: #9cbbe0;
    --ai-wash: #1f2a38;
    --ok: #4f9f70;
    --off: #8a8983;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
[hidden] { display: none !important; }
a { color: inherit; }

/* ------------------------------------------------------------ 上の帯 */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; text-decoration: none; font-size: var(--fs-lg); }
.brand small { font-weight: 400; color: var(--ink-soft); font-size: var(--fs-sm); letter-spacing: .04em; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px;
  background: var(--shu); color: #fff; font-size: 16px;
}
.who { display: flex; align-items: center; gap: 14px; font-size: var(--fs-sm); color: var(--ink-soft); }
.link { background: none; border: 0; padding: 0; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: var(--fs-sm); }
.link:hover { color: var(--shu); }
.link:disabled { opacity: .4; cursor: default; text-decoration: none; }

/* ------------------------------------------------------------ 机 */
.desk { width: min(1200px, 100%); margin: 0 auto; padding: 24px clamp(16px, 4vw, 40px) 40px; flex: 1; }

.controls { margin-top: 18px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px 32px; align-items: center; }
.langs { display: flex; align-items: end; gap: 10px; }
.langs .field { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; color: var(--ink-soft); }
select, input[type="text"], input[type="email"], .advanced textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--rule-strong); border-radius: 8px; background: var(--sheet);
}
select:focus, input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--shu); outline-offset: 1px; }
.swap {
  width: 42px; height: 42px; flex: none; border-radius: 50%; border: 1px solid var(--rule-strong);
  background: var(--sheet); cursor: pointer; font-size: 18px; color: var(--ink-soft);
}
.swap:hover { color: var(--shu); border-color: var(--shu); }
.swap:disabled { opacity: .35; cursor: default; }

/* モデル: 3枚の札。目盛りは品質の目安（細いほど速い） */
.models { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.model {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 2px 10px; align-items: baseline;
  text-align: left; padding: 10px 14px; border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--sheet); cursor: pointer; box-shadow: var(--shadow);
}
.model:hover { border-color: var(--ink-soft); }
.model[aria-checked="true"] { border-color: var(--shu); background: var(--shu-wash); box-shadow: inset 0 0 0 1px var(--shu); }
.model[aria-disabled="true"] { cursor: not-allowed; opacity: .55; }
.model-size { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-xl); letter-spacing: -.02em; grid-row: span 2; }
.model-name { font-size: var(--fs-sm); font-weight: 600; }
.model-use { grid-column: 1 / -1; font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
.model-short { display: none; }
.model-state { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.lamp { width: 7px; height: 7px; border-radius: 50%; background: var(--off); }
.model[data-up="true"] .lamp { background: var(--ok); }
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; padding: 0 14px; white-space: nowrap; flex: none;
  border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--sheet); color: var(--ink);
  font-size: var(--fs-sm); text-decoration: none; cursor: pointer;
}
.chip:hover { border-color: var(--shu); color: var(--shu); }
.model-hint { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink-soft); }

/* ------------------------------------------------------------ タブ */
.tabs { display: flex; gap: 4px; margin: 28px 0 0; border-bottom: 1px solid var(--rule-strong); }
.tab {
  padding: 8px 18px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0;
  background: none; cursor: pointer; color: var(--ink-soft); margin-bottom: -1px;
}
.tab[aria-selected="true"] { background: var(--sheet); border-color: var(--rule-strong); color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------ 校正紙（原文 | 訳文） */
.sheet {
  display: grid; grid-template-columns: 1fr 1fr; background: var(--sheet);
  border: 1px solid var(--rule-strong); border-top: 0; border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow); min-height: 360px;
}
.pane { display: flex; flex-direction: column; min-width: 0; }
.pane-src { border-right: 1px solid var(--rule); }
.pane-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 18px; border-bottom: 1px dashed var(--rule);
}
.pane-title { font-size: var(--fs-sm); font-weight: 700; letter-spacing: .2em; }
.pane-out .pane-title { color: var(--ai); }
.pane-out .pane-head { box-shadow: inset 0 3px 0 var(--ai); background: var(--ai-wash); }
.pane-head { min-height: 52px; }
.pane-tools { display: flex; gap: 14px; }
.counter { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--shu); font-weight: 700; }
#text::placeholder { color: var(--ink-soft); opacity: 1; }
#text {
  flex: 1; width: 100%; min-height: 320px; resize: vertical; border: 0; padding: 16px 18px; background: transparent;
  line-height: 1.85;
}
#text:focus { outline: none; }
.pane-src:focus-within { box-shadow: inset 3px 0 0 var(--shu); }
.output { flex: 1; padding: 16px 18px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; background: linear-gradient(var(--ai-wash), var(--ai-wash)) left / 3px 100% no-repeat; }
.output .placeholder { color: var(--ink-soft); margin: 0; white-space: normal; }

.sheet-file { display: block; padding: 22px; min-height: 0; }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  padding: 40px 20px; border: 2px dashed var(--rule-strong); border-radius: var(--radius); cursor: pointer; background: var(--paper);
}
.drop:hover, .drop.drag { border-color: var(--shu); background: var(--shu-wash); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--shu); outline-offset: 2px; }
.drop-main { font-weight: 600; }
.drop-sub { font-size: var(--fs-sm); color: var(--ink-soft); }
.drop.has-file .drop-main { color: var(--ai); }
.file-notes { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: var(--fs-sm); color: var(--ink-soft); }
.file-notes b { color: var(--ink); margin-right: .6em; }
.file-notes em { font-style: normal; color: var(--shu-deep); font-weight: 600; }

/* ------------------------------------------------------------ 詳しい設定 */
.advanced { margin-top: 16px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); }
.advanced summary { padding: 10px 16px; cursor: pointer; font-size: 14px; color: var(--ink-soft); }
.advanced-body { display: grid; grid-template-columns: 1fr 2fr; gap: 14px 20px; padding: 4px 16px 16px; }
.field-wide { grid-column: 1 / -1; }
.check { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; font-size: var(--fs-sm); }

/* ------------------------------------------------------------ 実行・進捗 */
.actions { display: flex; align-items: center; gap: 14px; margin-top: 20px; flex-wrap: wrap; }
.btn-primary {
  min-height: 48px; padding: 12px 40px; border: 0; border-radius: 6px; background: var(--shu); color: #fff; font-weight: 700;
  cursor: pointer; letter-spacing: .1em;
}
.btn-primary:hover { background: var(--shu-deep); }
.btn-primary:disabled { background: var(--off); cursor: default; }
.btn-ghost { min-height: 48px; padding: 10px 20px; border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--sheet); cursor: pointer; }
.btn-ghost:hover { border-color: var(--shu); color: var(--shu); }
.message { margin: 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.message.error { color: var(--shu-deep); font-weight: 600; }

.progress { margin-top: 18px; padding: 14px 18px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet); }
.progress-row { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.progress-track { height: 8px; margin: 10px 0 8px; border-radius: 4px; background: var(--rule); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--shu); border-radius: 4px; transition: width .4s ease; }
.progress-note { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ 最近の翻訳 */
.history { margin-top: 40px; }
.history h2 { font-size: var(--fs-lg); margin: 0 0 10px; }
.history h2 small { font-size: var(--fs-sm); font-weight: 400; color: var(--ink-soft); }
.history ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.history li { display: grid; grid-template-columns: 5.5em 1fr 15em; gap: 4px 14px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--rule); font-size: 14px; }
.history .when { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.history .what { min-width: 0; display: grid; grid-template-columns: minmax(0, auto) auto; justify-content: start; gap: 2px 10px; }
.history .what-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.history .state { font-size: 13px; color: var(--ink-soft); }
.history .state-error { color: var(--shu-deep); font-weight: 600; }
.history .what-detail { grid-column: 1 / -1; font-size: 13px; color: var(--ink-soft); }
.history .what .tag { display: inline-block; margin-right: 8px; padding: 0 7px; border-radius: 4px; background: var(--paper); border: 1px solid var(--rule); font-size: 12px; color: var(--ink); }
.history .row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.history .empty { color: var(--ink-soft); grid-template-columns: 1fr; }

.footer { padding: 18px clamp(16px, 4vw, 40px) 28px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--ink-soft); }
.footer p { margin: 2px 0; }

/* ------------------------------------------------------------ ログイン・メンバー */
.login-wrap { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(420px, 100%); padding: 36px 32px; background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: 14px; text-align: center; box-shadow: var(--shadow); }
.login-card .brand-mark { width: 52px; height: 52px; font-size: 26px; border-radius: 12px; }
.login-card h1 { font-size: var(--fs-xl); margin: 16px 0 4px; }
.login-card p { color: var(--ink-soft); font-size: var(--fs-sm); }
.google-btn {
  display: inline-flex; align-items: center; gap: 10px; margin: 18px 0 6px; padding: 11px 22px;
  border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--sheet); text-decoration: none; font-weight: 600;
}
.google-btn svg { width: 18px; height: 18px; }
.google-btn:hover { border-color: var(--shu); }

.panel { margin-top: 20px; padding: 18px 20px; background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: var(--radius); }
.panel-head { display: flex; gap: 10px; font-weight: 700; }
.panel-head .spacer { flex: 1; }
.hint-row { font-size: var(--fs-sm); color: var(--ink-soft); margin: 8px 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.toolbar input { flex: 1 1 220px; width: auto; }
.member-list { list-style: none; margin: 10px 0 0; padding: 0; }
.member-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--rule); }
.member-list .sub { font-size: 12px; color: var(--ink-soft); }
.member-list button { grid-row: span 2; align-self: center; }

/* ------------------------------------------------------------ 狭い画面 */
@media (max-width: 860px) {
  .controls { grid-template-columns: 1fr; }
  .sheet { grid-template-columns: 1fr; }
  .pane-src { border-right: 0; border-bottom: 1px solid var(--rule); }
  #text { min-height: 200px; }
  .advanced-body { grid-template-columns: 1fr; }
  .history li { grid-template-columns: 1fr; }
  .history .row-actions { justify-content: flex-start; }
  .history .when { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .brand small { display: none; }
  .desk { padding-top: 12px; }
  .controls { gap: 12px; }
  .models { gap: 6px; }
  .model { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 6px 4px; text-align: center; min-height: 56px; }
  .model-size { font-size: var(--fs-lg); line-height: 1.2; }
  .model-name { font-size: 12px; }
  .model-use, .model-speed { display: none; }
  .model-short { display: block; font-size: 12px; color: var(--ink-soft); }
  .model-hint { font-size: 13px; }
  #text { min-height: 180px; resize: none; }
  .output { min-height: 160px; }
  .output:has(.placeholder) { min-height: 96px; }
  .model-state { position: absolute; top: 6px; right: 6px; margin: 0; }
  .model { position: relative; }
  .tabs { margin-top: 16px; }
  .actions .btn-primary { flex: 1 1 100%; }
}
