:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #16a34a;
  --okbg: #ecfdf5;
  --err: #dc2626;
  --errbg: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 720px; margin: 0 auto; padding: 0 16px 40px; }

.app-header {
  background: linear-gradient(135deg, #0f172a, #1e3a8a);
  color: #fff; text-align: center;
  padding: 28px 16px 24px; margin-bottom: 20px;
}
.app-header h1 { margin: 0; font-size: 1.45rem; letter-spacing: .01em; }
.tagline { margin: 8px 0 0; opacity: .85; font-size: .9rem; }
.tagline b { color: #93c5fd; font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 18px;
}

/* ドロップゾーン */
.dropzone {
  display: block; border: 2px dashed #cbd5e1; border-radius: var(--radius);
  padding: 30px 16px; text-align: center; cursor: pointer;
  transition: .15s; background: #f8fafc;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: #eff6ff; }
.dropzone.has-file { border-style: solid; border-color: var(--ok); background: var(--okbg); }
.dz-icon { font-size: 2rem; }
.dz-text { font-weight: 600; margin-top: 6px; }
.dz-sub { color: var(--muted); font-size: .82rem; margin-top: 4px; }

/* 入り口の2系統ガイド */
.intake { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.intake-item {
  display: flex; align-items: flex-start; gap: 10px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: .9rem; font-weight: 600; color: var(--ink);
}
.intake-no { color: var(--accent); font-weight: 700; }
.intake-item small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; margin-top: 2px; }

/* URLから取り込み */
.url-sep { text-align: center; color: var(--muted); font-size: .78rem; margin: 14px 0 8px; }
.url-intake { display: flex; gap: 8px; }
.url-field {
  flex: 1; min-width: 0; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: .95rem; font-family: inherit; background: #fff; color: var(--ink);
}
.url-field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.url-intake .url-btn { width: auto; margin-top: 0; white-space: nowrap; flex-shrink: 0; }
.url-hint { margin-top: 8px; }

/* 入力フィールド */
.fields { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field .opt { font-weight: 400; color: #94a3b8; font-size: .75rem; }
.field input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 1rem; font-family: inherit; background: #fff; color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* ボタン */
.btn-primary, .btn-secondary {
  width: 100%; padding: 14px; border: none; border-radius: 12px;
  font-size: 1.02rem; font-weight: 700; cursor: pointer; margin-top: 18px;
  font-family: inherit; transition: .15s;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: #cbd5e1; cursor: not-allowed; }
.btn-secondary { background: #f1f5f9; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: #e2e8f0; }
.hint { font-size: .78rem; color: var(--muted); text-align: center; margin: 12px 0 0; }

/* 進捗 */
.progress-card { text-align: center; }
.spinner {
  width: 40px; height: 40px; margin: 4px auto 14px;
  border: 4px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-stage { font-size: 1.1rem; font-weight: 700; }
.progress-detail { color: var(--muted); font-size: .85rem; min-height: 1.2em; }
.progress-elapsed { color: #94a3b8; font-size: .8rem; margin-top: 4px; font-variant-numeric: tabular-nums; }
.steps { list-style: none; padding: 0; margin: 18px 0 0; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.steps li {
  font-size: .78rem; color: var(--muted); padding: 5px 11px;
  border-radius: 999px; background: #f1f5f9; border: 1px solid var(--line);
}
.steps li.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.steps li.done { background: var(--okbg); color: var(--ok); border-color: #bbf7d0; }

/* エラー */
.error-card { border-color: #fecaca; background: var(--errbg); }
.error-title { font-weight: 700; color: var(--err); }
.error-msg { margin: 8px 0 4px; font-size: .92rem; white-space: pre-wrap; }

/* 結果 */
.saved-banner {
  background: var(--okbg); border: 1px solid #bbf7d0; color: #166534;
  border-radius: var(--radius); padding: 12px 14px; font-size: .88rem; margin-bottom: 14px;
}
.saved-banner b { color: #15803d; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab {
  flex: 1; padding: 10px; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; font-size: .9rem; font-weight: 600; cursor: pointer; color: var(--muted);
  font-family: inherit;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* X投稿カード */
.xpost {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.xpost-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.xpost-label { font-size: .8rem; font-weight: 700; color: var(--accent); }
.xpost-body { white-space: pre-wrap; font-size: .98rem; }
.xpost-count { font-size: .75rem; color: var(--muted); margin-top: 8px; text-align: right; }

/* コピー */
.btn-copy {
  border: 1px solid var(--line); background: #fff; color: var(--accent);
  border-radius: 8px; padding: 6px 12px; font-size: .8rem; font-weight: 700; cursor: pointer; font-family: inherit;
}
.btn-copy:hover { background: #eff6ff; }
.btn-copy.copied { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-copy.posted { background: var(--ok); color: #fff; border-color: var(--ok); }
.panel-actions { display: flex; justify-content: flex-end; margin-bottom: 10px; }

/* X投稿カードのボタン群 */
.xpost-actions { display: flex; gap: 6px; }
.btn-x { background: #0f172a; color: #fff; border-color: #0f172a; }
.btn-x:hover { background: #000; }
.btn-x.posted { background: var(--ok); border-color: var(--ok); }
.xpost-count.over { color: var(--err); font-weight: 600; }

/* 最近の生成ビュー */
.recent-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.recent-head h2 { margin: 0; font-size: 1.2rem; }
.recent-item { margin-bottom: 24px; }
.recent-title { font-weight: 700; font-size: .95rem; margin: 12px 0 10px; padding-left: 8px; border-left: 3px solid var(--accent); }

/* 議事録Markdown表示 */
.md {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
}
.md h2 { font-size: 1.2rem; margin: 0 0 10px; }
.md h3 { font-size: 1.05rem; margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--line); }
.md h4 { font-size: .95rem; margin: 14px 0 6px; color: #334155; }
.md ul { margin: 6px 0; padding-left: 22px; }
.md ul.tasks { list-style: none; padding-left: 4px; }
.md ul.tasks li { margin: 3px 0; }
.md p { margin: 8px 0; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

.transcript {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; white-space: pre-wrap;
  font-family: inherit; font-size: .92rem; max-height: 60vh; overflow: auto; margin: 0;
}
.hidden-raw { position: absolute; left: -9999px; opacity: 0; }
.hidden { display: none !important; }

.app-footer { text-align: center; color: var(--muted); font-size: .78rem; padding: 0 16px 30px; }

/* ログイン画面 */
.login-gate {
  position: fixed; inset: 0; z-index: 1000;
  background: linear-gradient(135deg, #0f172a, #1e3a8a);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px 28px; text-align: center; max-width: 360px; width: 100%;
}
.login-emoji { font-size: 2.4rem; }
.login-card h2 { margin: 6px 0 4px; font-size: 1.3rem; }
.login-card #gbtn { display: flex; justify-content: center; margin: 18px 0 6px; }

@media (max-width: 480px) {
  .field-row { flex-direction: column; }
  .app-header h1 { font-size: 1.2rem; }
}
