/* ============================================================================
   ききとり — スタイル

   設計方針（要件 7）:
     - スマホ縦画面（幅 360〜420px）を第一に設計する
     - ボタンは指でタップしやすいサイズ（高さ 48px 以上）にする
     - Galaxy Z Fold8 の展開時（横に広い画面）にも対応する
     - 装飾は最小限。速度と分かりやすさを優先する
   ============================================================================ */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #d8dce3;
  --text: #1b1f26;
  --text-muted: #5c6470;
  --primary: #14607a;
  --primary-dark: #0f4c60;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --success: #1b6b3a;
  --success-bg: #e8f5ec;
  --warn-bg: #fff6e5;
  --radius: 10px;
  --tap: 48px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo",
               system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- ヘッダー ------------------------------------------------------------ */

.site-header {
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: max(10px, env(safe-area-inset-top));
}

.brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  margin-right: auto;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a,
.link-button {
  color: #fff;
  text-decoration: none;
  padding: 10px;
  border-radius: 6px;
  font-size: 0.95rem;
  min-height: 44px; /* 指でタップしやすい最小サイズ */
  display: inline-flex;
  align-items: center;
}

.site-nav a.current { background: rgba(255, 255, 255, 0.22); font-weight: 700; }
.site-nav a:hover, .link-button:hover { background: rgba(255, 255, 255, 0.14); }

.link-button {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
}

.link-button.danger { color: var(--danger); }

.site-user {
  font-size: 0.85rem;
  opacity: 0.9;
  white-space: nowrap;
}

.inline-form { display: inline; margin: 0; }

/* --- レイアウト ---------------------------------------------------------- */

.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 14px 40px;
  flex: 1;
}

.site-footer {
  padding: 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer p { margin: 0; }

.page-title { font-size: 1.35rem; margin: 4px 0 16px; line-height: 1.4; }
.card-title { font-size: 1.05rem; margin: 0 0 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
}

details.card > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  min-height: 44px; /* 指でタップしやすい最小サイズ */
  display: flex;
  align-items: center;
}

details.card > summary::before { content: "＋ "; color: var(--primary); }
details.card[open] > summary::before { content: "− "; }
details.card[open] > summary { margin-bottom: 12px; }

.stack > * + * { margin-top: 14px; }

.muted { color: var(--text-muted); font-size: 0.9rem; }
.hint { color: var(--text-muted); font-size: 0.85rem; margin: 8px 0 0; }
.hint-center { text-align: center; }

/* --- フラッシュメッセージ ------------------------------------------------ */

.flashes { margin-bottom: 16px; }

.flash {
  margin: 0 0 8px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  border: 1px solid transparent;
}

.flash-error { background: var(--danger-bg); border-color: #f3c2be; color: var(--danger); }
.flash-info { background: var(--success-bg); border-color: #bfe0c9; color: var(--success); }

.notice {
  background: var(--danger-bg);
  border: 1px solid #f3c2be;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

.notice strong { display: block; color: var(--danger); margin-bottom: 4px; }
.notice p { margin: 0; }

/* --- フォーム ------------------------------------------------------------ */

.field { display: block; margin-bottom: 16px; border: none; padding: 0; }

.field-label {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 6px;
}

.required, .optional {
  font-weight: 400;
  font-size: 0.78rem;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: middle;
}

.required { background: var(--danger-bg); color: var(--danger); }
.optional { background: #eceff3; color: var(--text-muted); }

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font-size: 16px; /* iOS/Android で自動ズームさせないため 16px 以上 */
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}

input:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #7fb7c8;
  outline-offset: 1px;
}

.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  background: #fff;
}

.check input { width: 22px; height: 22px; margin-top: 2px; flex-shrink: 0; }
.check strong { display: block; }
.check small { display: block; color: var(--text-muted); font-size: 0.82rem; line-height: 1.5; }
.check-disabled { opacity: 0.55; cursor: not-allowed; background: #f2f3f5; }

/* --- ボタン -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--primary); border-color: var(--border); }
.btn-ghost:hover { background: #eef4f6; }
.btn-danger { background: #fff; color: var(--danger); border-color: #e3b5b1; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-block { display: flex; width: 100%; margin-top: 8px; }
.btn[disabled] { opacity: 0.5; cursor: progress; }

.page-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.page-actions .btn { flex: 1 1 auto; }

/* --- ファイル選択 -------------------------------------------------------- */

.dropzone {
  position: relative;
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  background: #eef4f6;
  text-align: center;
  padding: 4px;
}

.dropzone.dragover { background: #dceaef; border-style: solid; }
.dropzone input[type="file"] { position: absolute; opacity: 0; width: 1px; height: 1px; }

.dropzone-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 26px 12px;
  cursor: pointer;
}

.dropzone-icon { font-size: 1.9rem; color: var(--primary); line-height: 1; }
.dropzone-main { font-weight: 700; font-size: 1.05rem; color: var(--primary); }
.dropzone-sub { font-size: 0.8rem; color: var(--text-muted); }

.dropzone-file {
  margin: 0;
  padding: 10px 12px;
  background: #fff;
  border-radius: 8px;
  font-size: 0.88rem;
  word-break: break-all;
  text-align: left;
}

/* --- 進捗 ---------------------------------------------------------------- */

.status-line { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.status-label { font-size: 1.1rem; font-weight: 700; }

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #cfd6de;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex-shrink: 0;
}

.spinner[hidden] { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

.progress {
  height: 10px;
  background: #dfe3e9;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.progress-bar.failed { background: var(--danger); }

.meta-list { margin: 16px 0 0; padding: 0; font-size: 0.9rem; }
.meta-list > div { display: flex; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); }
.meta-list dt { color: var(--text-muted); min-width: 6.5em; flex-shrink: 0; margin: 0; }
.meta-list dd { margin: 0; word-break: break-all; }

/* --- 一覧 ---------------------------------------------------------------- */

.job-list { list-style: none; margin: 0 0 12px; padding: 0; }

.job-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  display: flex;
  align-items: stretch;
}

.job-item > a {
  flex: 1;
  display: block;
  padding: 14px;
  color: var(--text);
  text-decoration: none;
  min-height: var(--tap);
}

.job-item > a:hover { background: #eef4f6; border-radius: var(--radius); }
.job-title { display: block; font-weight: 700; margin-bottom: 4px; word-break: break-word; }

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  align-items: center;
}

.job-modes { display: block; font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.job-delete { display: flex; align-items: center; padding-right: 10px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #eceff3;
  color: var(--text-muted);
}

.badge-done { background: var(--success-bg); color: var(--success); }
.badge-failed { background: var(--danger-bg); color: var(--danger); }
.badge-queued, .badge-converting, .badge-transcribing, .badge-post_processing {
  background: var(--warn-bg);
  color: #8a5d00;
}

.empty { text-align: center; }
.empty p { margin-top: 0; }

.search-form { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-form input { flex: 1 1 180px; }
.search-form .btn { flex: 0 0 auto; }

/* --- 結果表示 ------------------------------------------------------------ */

.result-meta { margin-top: -8px; margin-bottom: 16px; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  min-height: var(--tap);
}

.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.result-actions .btn { flex: 1 1 auto; }

.result-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 10px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.9;
  max-height: 65vh;
  overflow-y: auto;
  -webkit-user-select: text;
  user-select: text;
}

/* --- 用語辞書 ------------------------------------------------------------ */

.glossary-list { list-style: none; margin: 0; padding: 0; }

.glossary-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.glossary-item summary {
  padding: 14px;
  cursor: pointer;
  min-height: var(--tap);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.glossary-item summary::-webkit-details-marker { display: none; }
.glossary-correct { font-weight: 700; }
.glossary-variants { font-size: 0.82rem; color: var(--text-muted); word-break: break-all; }
.glossary-edit { padding: 0 14px 14px; }
.glossary-item form:last-child { padding: 0 14px 14px; }

.chip {
  background: #eef4f6;
  color: var(--primary);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 0.76rem;
  font-weight: 700;
}

/* --- ログイン画面 -------------------------------------------------------- */

.login-wrap { max-width: 400px; margin: 6vh auto 0; }
.login-title { text-align: center; font-size: 1.8rem; margin: 0 0 4px; color: var(--primary); }
.login-lead { text-align: center; color: var(--text-muted); margin: 0 0 24px; font-size: 0.9rem; }
.btn-google { margin-top: 0; font-size: 1.05rem; min-height: 52px; }
.login-sub { margin: 28px 0 8px; font-size: 0.9rem; font-weight: 400; color: var(--text-muted); text-align: center; }
.login-password { padding-top: 12px; }

/* --- 広い画面（Galaxy Z Fold8 の展開時・PC）------------------------------ */

@media (min-width: 700px) {
  .container { padding: 24px 20px 48px; }
  .page-title { font-size: 1.6rem; }
  .result-actions .btn, .page-actions .btn { flex: 0 0 auto; }
  .job-meta { font-size: 0.85rem; }
}

@media (min-width: 1000px) {
  .container { max-width: 900px; }
  .result-text { max-height: 70vh; }
}

/* --- 印刷 ---------------------------------------------------------------- */

@media print {
  .site-header, .site-footer, .tabs, .result-actions, .page-actions { display: none; }
  .tab-panel { display: block !important; }
  .result-text { max-height: none; border: none; padding: 0; }
}
