/* BOOK:// STUDIO — 静かな編集室。紙と墨、上質な出版デザイン。ダッシュボード調・サイバー調は禁止 */
:root {
  --ink: #1c1a16;
  --ink-2: #4c463c;
  --ink-3: #8a8272;
  --paper: #f7f4ee;
  --paper-2: #fffdf9;
  --line: #e3ddd0;
  --gold: #a8862f;
  --gold-2: #c9a84c;
  --moss: #55603f;
  --alert: #a0421f;
  --ok: #3f6b4f;
  --serif: "Shippori Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --latin: "Cormorant Garamond", serif;
  --sans: "Inter", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(28,26,22,.06), 0 8px 24px rgba(28,26,22,.07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); font-size: 15px; line-height: 1.75; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .serif { font-family: var(--serif); font-weight: 600; letter-spacing: .02em; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--ink); }

.app { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: none; background: var(--paper-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: block; padding: 26px 22px 18px; border-bottom: 1px solid var(--line); }
.brand-book { font-family: var(--latin); font-size: 25px; font-weight: 600; letter-spacing: .04em; }
.brand-slash { color: var(--gold); }
.brand-sub { display: block; font-size: 10px; letter-spacing: .42em; color: var(--ink-3); margin-top: 2px; }
.side-nav { flex: 1; padding: 14px 10px; }
.nav-item { display: block; padding: 8px 12px; border-radius: var(--radius); color: var(--ink-2); font-size: 13.5px; margin-bottom: 1px; }
.nav-item:hover { background: var(--paper); }
.nav-item.active { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: inset 2px 0 0 var(--gold); }
.nav-item-accent { color: var(--gold); }
.nav-group { margin: 10px 0; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.nav-bottom { margin-top: 12px; }
.side-foot { padding: 14px 22px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.side-user { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.langtoggle { border: 1px solid var(--line); background: transparent; border-radius: 20px; padding: 3px 12px; font-size: 11px; color: var(--ink-2); }

.main { flex: 1; min-width: 0; padding: 40px 48px 80px; max-width: 1160px; }
.page-head { margin-bottom: 28px; }
.page-head h1 { font-size: 26px; }
.page-head .lead { color: var(--ink-2); margin-top: 6px; font-size: 14px; }
.crumb { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }
.crumb a:hover { color: var(--gold); }

.card { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 26px; margin-bottom: 18px; }
.card h2 { font-size: 17px; margin-bottom: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.hint { font-size: 12.5px; color: var(--ink-3); }
.rule { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.btn { display: inline-block; border: 1px solid var(--ink); background: var(--ink); color: var(--paper-2); border-radius: var(--radius); padding: 9px 20px; font-size: 14px; letter-spacing: .04em; transition: opacity .15s; }
.btn:hover { opacity: .82; }
.btn:disabled { opacity: .4; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--paper); opacity: 1; }
.btn-gold { background: var(--gold); border-color: var(--gold); }
.btn-danger { background: transparent; border-color: var(--alert); color: var(--alert); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; letter-spacing: .03em; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); background: var(--paper-2); border-radius: var(--radius); padding: 9px 12px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--gold); }
.field textarea { min-height: 110px; resize: vertical; line-height: 1.8; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; letter-spacing: .08em; color: var(--ink-3); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:hover td { background: rgba(168,134,47,.04); }

.badge { display: inline-block; font-size: 11px; border: 1px solid var(--line); border-radius: 20px; padding: 1px 10px; color: var(--ink-2); letter-spacing: .05em; }
.badge-gold { border-color: var(--gold); color: var(--gold); }
.badge-ok { border-color: var(--ok); color: var(--ok); }
.badge-alert { border-color: var(--alert); color: var(--alert); }
.badge-muted { color: var(--ink-3); }

mark.needs-check { background: #f6e8c8; color: #7a5a10; border-radius: 3px; padding: 0 4px; font-size: .92em; }

.loading { color: var(--ink-3); padding: 60px 0; text-align: center; letter-spacing: .1em; }
.loading::after { content: ""; display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; margin-left: 10px; vertical-align: -2px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--ink-3); text-align: center; padding: 60px 20px; }
.error-box { background: #faf1ec; border: 1px solid #e8cdbc; border-radius: var(--radius); padding: 24px; }
.error-box h2 { color: var(--alert); font-size: 16px; margin-bottom: 8px; }

.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper-2); border-radius: 30px; padding: 10px 26px; font-size: 13.5px; box-shadow: var(--shadow); z-index: 90; }
.toast-error { background: var(--alert); }
.toast-ok { background: var(--ok); }

.modal-back { position: fixed; inset: 0; background: rgba(28,26,22,.45); display: flex; align-items: center; justify-content: center; z-index: 80; padding: 20px; }
.modal { background: var(--paper-2); border-radius: 8px; max-width: 640px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 30px 32px; box-shadow: var(--shadow); }
.modal h2 { font-size: 18px; margin-bottom: 14px; }

/* AI生成の逐次表示 */
.ai-stream { background: var(--paper); border: 1px dashed var(--gold-2); border-radius: var(--radius); padding: 18px 20px; white-space: pre-wrap; font-size: 14px; line-height: 1.9; min-height: 60px; }
.ai-stream.running::after { content: "▍"; color: var(--gold); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.ai-note { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-3); margin-top: 8px; }

/* エディター */
.editor-wrap { display: grid; grid-template-columns: 1fr 240px; gap: 22px; align-items: start; }
.editor-paper { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 40px 44px; min-height: 60vh; }
.editor-paper textarea { width: 100%; border: 0; background: transparent; min-height: 55vh; font-family: var(--serif); font-size: 15.5px; line-height: 2.1; resize: vertical; }
.editor-paper textarea:focus { outline: none; }
.editor-title-input { width: 100%; border: 0; background: transparent; font-family: var(--serif); font-size: 22px; font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 18px; }
.editor-title-input:focus { outline: none; border-bottom-color: var(--gold); }
.editor-side { position: sticky; top: 24px; }
.tool-list button { display: block; width: 100%; text-align: left; background: transparent; border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 12px; margin-bottom: 6px; font-size: 12.5px; color: var(--ink-2); }
.tool-list button:hover { border-color: var(--gold); color: var(--ink); }
.savestate { font-size: 11.5px; color: var(--ink-3); letter-spacing: .05em; }

/* 本棚カード */
.shelf-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; gap: 16px; transition: box-shadow .15s; }
.shelf-card:hover { box-shadow: var(--shadow); }
.shelf-spine { width: 52px; height: 76px; border-radius: 2px 5px 5px 2px; background: linear-gradient(120deg, #3d3a33, #55523f); color: #f5eeda; font-family: var(--serif); font-size: 10px; writing-mode: vertical-rl; padding: 8px 0; text-align: center; overflow: hidden; flex: none; box-shadow: inset 3px 0 0 rgba(255,255,255,.14); }

/* 対訳ビュー */
.parallel { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.parallel > div { padding: 22px 24px; background: var(--paper-2); }
.parallel > div:first-child { border-right: 1px solid var(--line); background: var(--paper); }
.parallel h3 { font-size: 12px; letter-spacing: .12em; color: var(--ink-3); margin-bottom: 12px; }

/* 進捗バー */
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--gold); }

/* プレビュー(見開き) */
.spread { display: flex; gap: 2px; justify-content: center; background: #2e2b26; padding: 34px; border-radius: 8px; }
.page-sheet { background: #fffdf8; width: 340px; min-height: 480px; padding: 34px 30px; box-shadow: 0 3px 14px rgba(0,0,0,.4); font-family: var(--serif); font-size: 11.5px; line-height: 2; overflow: hidden; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.stat { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat b { display: block; font-family: var(--serif); font-size: 24px; font-weight: 600; }
.stat span { font-size: 11.5px; color: var(--ink-3); letter-spacing: .06em; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .side-nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav-group { border: 0; margin: 0; padding: 0; display: contents; }
  .nav-bottom { display: contents; }
  .main { padding: 22px 18px 60px; }
  .editor-wrap, .parallel { grid-template-columns: 1fr; }
  .editor-paper { padding: 24px 20px; }
  .spread { flex-direction: column; align-items: center; }
}
