:root {
  --navy: #1f3a5f;
  --navy-dark: #16293f;
  --bg: #f4f6f8;
  --card: #fff;
  --line: #d8dee6;
  --text: #1c242e;
  --muted: #6a7686;
  --danger: #b4232b;
  --ok: #1d7a4c;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* display を指定した要素にも hidden を効かせる */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2 { font-size: 1.15rem; margin: 0; }

.screen { max-width: 900px; margin: 0 auto; padding: 12px 16px 64px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); }

/* ---------------------------------------------------------- ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--danger); border-color: #e6c3c5; }
.btn.big { min-height: 52px; font-size: 1.05rem; padding: 0 22px; }
.btn.huge { min-height: 76px; font-size: 1.3rem; padding: 0 40px; }

/* ---------------------------------------------------------- 合言葉 */
#screen-login { display: grid; place-items: center; min-height: 80vh; }
.login-box { width: min(420px, 100%); text-align: center; }
.login-box h1 { margin-bottom: 8px; font-size: 1.4rem; }
#login-form { display: grid; gap: 12px; margin-top: 20px; }

/* ---------------------------------------------------------- 入力 */
input, textarea, select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
textarea { min-height: 120px; line-height: 1.75; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); }
label input, label textarea { margin-top: 4px; color: var(--text); font-size: 1rem; }
.block { margin-top: 16px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

/* ---------------------------------------------------------- ヘッダ・タブ */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.bar h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-actions { display: flex; align-items: center; gap: 8px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; }
.tab {
  flex: none;
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab.is-active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }

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

/* ---------------------------------------------------------- 一覧・検索 */
.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row input { flex: 1; }
.search-row select { width: auto; min-width: 150px; flex: none; }

.fy-group { margin-bottom: 22px; }
.fy-head {
  font-weight: 600;
  color: var(--navy);
  padding: 6px 0;
  border-bottom: 2px solid var(--navy);
  margin-bottom: 8px;
}

.card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.card .date { font-weight: 600; }
.card .meta { color: var(--muted); font-size: .85rem; margin-top: 2px; }

.tag {
  display: inline-block;
  font-size: .75rem;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e8edf3;
  color: var(--navy);
  margin-right: 4px;
}
.tag.hit { background: #fff2cc; color: #7a5c00; }
.tag.done { background: #e0f2e8; color: var(--ok); }

/* ---------------------------------------------------------- 録音 */
.rec-box {
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
}
.rec-time {
  font-size: 3rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: .02em;
}
.rec-box .btn { margin: 16px 0 12px; }
.rec-box.is-recording .rec-time { color: var(--danger); }
.rec-box.is-recording { border-color: var(--danger); }

.queue { margin-top: 16px; display: grid; gap: 6px; }
.queue-item {
  display: flex;
  gap: 10px;
  align-items: baseline;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .9rem;
}
.queue-item .at { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.queue-item .st { flex: none; font-size: .8rem; }
.queue-item.pending .st { color: var(--muted); }
.queue-item.done .st { color: var(--ok); }
.queue-item.failed .st { color: var(--danger); }

/* ---------------------------------------------------------- 資料 */
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.doc-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.doc-card .doc-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.doc-card .doc-head input { flex: 1; min-height: 40px; }

/* ---------------------------------------------------------- 逐語記録 */
.transcript {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 4px;
}
.tr-row { display: flex; gap: 12px; padding: 6px 12px; border-bottom: 1px solid #eef1f5; }
.tr-row:last-child { border-bottom: none; }
.tr-row .at { flex: none; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- 役員 */
dialog {
  width: min(560px, 92vw);
  border: none;
  border-radius: 14px;
  padding: 22px;
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog .doc-actions { margin-top: 16px; }
.of-list { margin-top: 8px; border-top: 1px solid var(--line); }
.of-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid #eef1f5; font-size: .9rem; }
.of-row .fy { flex: none; width: 90px; font-weight: 600; }

/* ---------------------------------------------------------- お知らせ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--navy-dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: .9rem;
  z-index: 100;
  max-width: 90vw;
}
.toast.bad { background: var(--danger); }

/* ---------------------------------------------------------- 印刷 */
#print-area { display: none; }

@media print {
  body { background: #fff; }
  .screen, dialog, .toast { display: none !important; }
  #print-area { display: block; font-size: 11pt; }
  #print-area h1 { text-align: center; font-size: 15pt; margin: 0 0 16pt; }
  #print-area table { border-collapse: collapse; width: 100%; margin-bottom: 14pt; }
  #print-area th, #print-area td { border: 1px solid #888; padding: 4pt 8pt; text-align: left; }
  #print-area th { width: 70pt; background: #f2f2f2; }
  #print-area .body { white-space: pre-wrap; line-height: 1.8; }
  @page { size: A4; margin: 18mm 16mm; }
}

/* ---------------------------------------------------------- 夜間 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151a21;
    --card: #1e242d;
    --line: #333c48;
    --text: #e8ecf1;
    --muted: #9aa6b4;
    --navy: #4a7fc1;
    --navy-dark: #0f151c;
  }
  .tag { background: #2a3340; color: #a8c4e6; }
  .tag.hit { background: #4a3d15; color: #f0d78a; }
  .tag.done { background: #1e3a2b; color: #7fd6a5; }
  .tr-row, .of-row { border-bottom-color: #2a3340; }
}
