:root {
  --sidebar-bg: #0f1b2a;
  --sidebar-fg: #c7d0da;
  --accent: #3fa2e0;
  --accent-dk: #2f8fce;
  --text: #2b3742;
  --muted: #7a8794;
  --line: #e8ebee;
  --hl: #d9ebfa;
  --bg: #ffffff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic",
    Meiryo, system-ui, sans-serif;
  color: var(--text);
  background: #f4f6f8;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--sidebar-bg); color: var(--sidebar-fg);
  display: flex; flex-direction: column;
  padding: 18px 14px;
}
.logo { font-size: 20px; font-weight: 700; color: #fff; margin: 6px 6px 22px; }
.logo-mark { margin-right: 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--sidebar-fg);
}
.nav-item:hover { background: rgba(255,255,255,.06); }
.nav-item.active { background: rgba(255,255,255,.10); color: #8fc7ee; }
.nav-ico { width: 18px; text-align: center; }

.user { margin-top: auto; padding: 6px; font-size: 13px; color: #9fb0c0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { flex-shrink: 0; background: rgba(255,255,255,.08); color: #cfd8e0;
  border: 0; border-radius: 6px; padding: 5px 9px; font-size: 11px; cursor: pointer; }
.logout-btn:hover { background: rgba(255,255,255,.16); }

/* ---------------- Login gate ---------------- */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, #1c2c3e, #0f1b2a);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 44px 40px; width: 360px; max-width: 90vw;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo { font-size: 26px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 14px; margin: 4px 0 24px; }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
.login-error {
  margin: 16px 0 0; padding: 10px 12px; border-radius: 8px;
  background: #fdecea; color: #b3261e; font-size: 13px; line-height: 1.5;
}
.login-note { margin-top: 22px; color: #9aa5af; font-size: 12px; line-height: 1.5; }

/* ---------------- Main ---------------- */
.main { flex: 1; position: relative; background: var(--bg); overflow: hidden; display: flex; flex-direction: column; }

/* ---- List view ---- */
#list-view { display: flex; flex-direction: column; height: 100%; }
.topbar {
  display: flex; justify-content: flex-end; align-items: center;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: #1a2735;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.cal-ico { color: #cdd6df; }
.search {
  width: 320px; padding: 8px 14px; border-radius: 18px;
  border: 1px solid #cfd6dd; font-size: 14px; outline: none;
}

.list-wrap { flex: 1; overflow: auto; padding: 8px 24px 120px; }
.rec-table { width: 100%; border-collapse: collapse; }
.rec-table thead th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 14px 10px; border-bottom: 1px solid var(--line);
}
.col-date { width: 130px; }
.col-dur { width: 90px; text-align: right; }
.col-menu { width: 30px; }
.rec-table td { padding: 16px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13px; }
.rec-row { cursor: pointer; }
.rec-row:hover { background: #f6f9fb; }
.row-title { font-weight: 700; font-size: 15px; color: var(--text); }
.row-preview { color: var(--muted); margin-top: 6px; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }
.row-date { color: var(--muted); white-space: nowrap; }
.row-dur { text-align: right; color: var(--text); }
.row-menu { text-align: center; }
.kebab { background: none; border: 0; color: #b3bcc4; font-size: 18px; line-height: 1;
  cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.kebab:hover { background: #eef2f6; color: #6b7680; }

/* Row context menu (⋮ dropdown) */
.row-menu-pop {
  position: fixed; z-index: 50; min-width: 180px; padding: 6px 0;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.16);
}
.row-menu-pop button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 11px 18px; font-size: 14px; color: var(--text); cursor: pointer;
}
.row-menu-pop button:hover { background: #f4f9fd; }

/* Modal (download dialog) */
.modal-overlay {
  position: fixed; inset: 0; z-index: 70; display: flex;
  align-items: center; justify-content: center; background: rgba(20,28,38,.55);
}
.modal-card {
  position: relative; background: #fff; border-radius: 14px; padding: 30px 34px;
  width: 480px; max-width: 92vw; box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.modal-close { position: absolute; top: 14px; right: 16px; background: none; border: 0;
  font-size: 22px; color: #98a3ad; cursor: pointer; line-height: 1; }
.modal-title { text-align: center; font-size: 20px; margin: 4px 0 4px; }
.modal-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.dl-field-label { font-size: 13px; color: var(--text); margin: 16px 0 6px; font-weight: 600; }
.dl-select { width: 100%; padding: 10px 12px; border: 1px solid #cfd6dd; border-radius: 8px;
  font-size: 14px; background: #fff; }
.dl-items { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px 10px; margin-top: 4px; }
.dl-items label { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.dl-items input { accent-color: var(--accent); }
.modal-actions { display: flex; justify-content: center; gap: 14px; margin-top: 28px; }
.modal-btn { padding: 11px 30px; border: 0; border-radius: 22px; font-size: 14px; cursor: pointer; }
.modal-btn.ghost { background: #eef2f6; color: var(--text); }
.modal-btn.primary { background: var(--accent); color: #fff; }
.modal-btn.primary:hover { background: var(--accent-dk); }

/* Upload dialog */
.upload-card { width: 560px; }
.drop-zone {
  border: 2px dashed #cdd6df; border-radius: 12px; padding: 30px 20px; margin: 8px 0 14px;
  text-align: center; min-height: 150px; display: flex; align-items: center; justify-content: center;
}
.drop-zone.dragover { border-color: var(--accent); background: #f2f9fe; }
.drop-icon { font-size: 34px; margin-bottom: 10px; }
.drop-text { color: var(--muted); font-size: 13px; margin: 0 0 10px; line-height: 1.6; }
.drop-sub { font-size: 12px; color: #9aa5af; }
.link-btn { background: none; border: 0; color: var(--accent); font-size: 13px; cursor: pointer; }
.drop-selected { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.file-icon { font-size: 40px; }
.file-name { font-size: 15px; color: var(--text); }
.ext-note { font-size: 11px; color: var(--muted); line-height: 1.6; margin: 0 0 12px; }
.lang-row { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 13px; margin-bottom: 8px; }
.lang-select { width: auto; padding: 6px 12px; }
.modal-btn.primary:disabled { background: #bcd4e6; cursor: default; }

.transcript-status { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* Processing (transcription-in-progress) pencil */
.pencil-anim {
  display: inline-block; margin-right: 8px; color: var(--accent); vertical-align: middle;
  transform-origin: 70% 90%; animation: pencil-wiggle 0.85s ease-in-out infinite;
}
@keyframes pencil-wiggle {
  0%, 100% { transform: rotate(-14deg); }
  50% { transform: rotate(10deg); }
}

/* Toast */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: rgba(30,40,52,.94); color: #fff; padding: 11px 20px; border-radius: 22px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.badge-new { font-size: 11px; color: var(--accent); margin-left: 8px; }
.list-empty { padding: 60px; text-align: center; color: var(--muted); }

.fab-bar {
  position: absolute; bottom: 26px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 18px; pointer-events: none;
}
.fab {
  pointer-events: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 13px 34px; border: 0; border-radius: 26px;
  background: var(--accent); color: #fff; font-size: 15px; cursor: pointer;
  box-shadow: 0 6px 16px rgba(63,162,224,.35);
}
.fab:hover { background: var(--accent-dk); }
.fab.recording { background: #e0554a; box-shadow: 0 6px 16px rgba(224,85,74,.4); }

/* ---- Detail view ---- */
#detail-view { display: flex; flex-direction: column; height: 100%; }
.detail-top {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; background: #1a2735; color: #eef2f6;
}
.back { background: none; border: 0; color: #eef2f6; font-size: 26px; cursor: pointer; line-height: 1; }
.detail-title { font-size: 17px; margin: 0; font-weight: 600; }
.detail-dates { margin-left: auto; display: flex; gap: 18px; font-size: 11px; color: #9fb0c0; }
.detail-actions { display: flex; gap: 8px; }
.ghost-btn { background: rgba(255,255,255,.08); color: #dfe7ee; border: 0; padding: 7px 12px;
  border-radius: 16px; font-size: 12px; cursor: pointer; }

.detail-body { flex: 1; display: flex; overflow: hidden; }
.transcript-pane { flex: 1.7; display: flex; flex-direction: column; border-right: 1px solid var(--line); min-width: 0; }
.transcript-tabs { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; font-size: 13px; color: var(--muted); cursor: pointer; padding: 6px 4px; }
.tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); font-weight: 600; }
.meta-badge { margin-left: auto; font-size: 11px; color: var(--muted); }

.transcript { flex: 1; overflow: auto; padding: 8px 12px; }
.cue {
  display: grid; grid-template-columns: 44px 1fr; gap: 4px 12px;
  padding: 12px 14px; border-radius: 10px; cursor: pointer; align-items: start;
}
.cue:hover { background: #f4f9fd; }
.cue.active { background: var(--hl); }
.cue-avatar {
  grid-row: span 2; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
}
.cue-head { display: flex; align-items: baseline; gap: 10px; }
.cue-spk { font-weight: 700; font-size: 13px; }
.cue-time { color: var(--muted); font-size: 12px; }
.cue-text { grid-column: 2; line-height: 1.6; font-size: 14px; }

.unprocessed { padding: 60px 20px; text-align: center; color: var(--muted); }
.primary-btn {
  margin-top: 8px; padding: 12px 34px; border: 0; border-radius: 24px;
  background: var(--accent); color: #fff; font-size: 15px; cursor: pointer;
}
.primary-btn:disabled { opacity: .6; cursor: default; }
.progress { margin-top: 18px; color: var(--text); font-size: 14px; }

.side-pane { flex: 1; overflow: auto; padding: 16px; background: #fafbfc; min-width: 240px; }
.side-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.side-card h3 { margin: 0 0 10px; font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0; }

/* ---- Player ---- */
.player {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-top: 1px solid var(--line); background: #fff;
}
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text); }
.time-sep { color: var(--muted); }
.pl-btn { background: #eef2f6; border: 0; border-radius: 16px; padding: 8px 12px;
  font-size: 13px; cursor: pointer; color: var(--text); }
.pl-btn.play { background: var(--accent); color: #fff; width: 44px; }
.pl-btn.speed { min-width: 48px; }
.seek { flex: 1; accent-color: var(--accent); }
