/* Màu và bo góc lấy từ res/values/colors.xml của app Android để web giống app. */
:root {
  --primary: #1A73E8;
  --primary-container: #E8F0FE;
  --rec-red: #E53935;
  --rec-red-container: #FDECEA;
  --warn: #F57C00;
  --warn-container: #FFF4E5;
  --warn-text: #A65100;
  --ok: #2E7D32;
  --ok-container: #E6F4EA;
  --surface: #FFFFFF;
  --background: #F5F7FA;
  --box-grey: #F1F4F8;
  --chip-grey: #EDEFF2;
  --on-surface: #1F2933;
  --on-surface-variant: #6B7785;
  --divider: #E3E8EE;
  --disabled: #B0B8C4;
  --radius: 12px;
  --gutter: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--on-surface);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--background); }
body { min-height: 100vh; font-size: 15px; line-height: 1.45; }
h1, h2, h3 { margin: 0; font-weight: 600; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-bottom: 1px solid var(--divider);
  padding: var(--gutter); display: flex; flex-direction: column; gap: 12px; }
.sidebar h1 { font-size: 20px; }
.subtitle { color: var(--on-surface-variant); font-size: 13px; }
.filter-list { display: flex; flex-wrap: wrap; gap: 8px; }
.filter { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: 1px solid var(--divider); background: var(--surface); color: var(--on-surface);
  border-radius: 999px; padding: 8px 14px; min-height: 44px; }
.filter[aria-pressed="true"] { background: var(--primary-container); border-color: var(--primary);
  color: var(--primary); font-weight: 600; }
.filter .count { color: var(--on-surface-variant); font-size: 13px; }
.content { padding: var(--gutter); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .grow { flex: 1 1 200px; min-width: 160px; }
.search { width: 100%; min-height: 44px; border: 1px solid var(--divider); border-radius: var(--radius);
  padding: 0 12px; background: var(--surface); font: inherit; color: inherit; }
.chips { display: flex; gap: 8px; }
.chip { border: 1px solid var(--divider); background: var(--chip-grey); border-radius: 999px;
  padding: 6px 14px; min-height: 36px; color: var(--on-surface); }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

.btn { min-height: 44px; border-radius: var(--radius); border: 1px solid var(--divider);
  background: var(--surface); color: var(--on-surface); padding: 0 16px; font-weight: 500; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { background: var(--rec-red); border-color: var(--rec-red); color: #fff; }
.btn.text { border-color: transparent; background: transparent; color: var(--primary); }
.btn:disabled { opacity: .5; }
.btn.block { width: 100%; }

.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--divider);
  padding: 14px; display: flex; flex-direction: column; gap: 8px; position: relative; cursor: pointer; }
.card button { cursor: default; }
.card .menu button, .card .btn { cursor: pointer; }
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card-title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.card-meta { color: var(--on-surface-variant); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.card-summary { color: var(--on-surface); font-size: 14px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-summary .prefix { color: var(--on-surface-variant); font-weight: 600; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.menu-btn { border: none; background: transparent; width: 44px; height: 44px; margin: -8px -8px 0 0;
  border-radius: 999px; font-size: 20px; color: var(--on-surface-variant); }
.menu-btn:hover { background: var(--box-grey); }
.menu { position: absolute; right: 12px; top: 44px; z-index: 5; background: var(--surface);
  border: 1px solid var(--divider); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.12);
  min-width: 200px; padding: 4px; }
.menu button { display: block; width: 100%; text-align: left; min-height: 44px; border: none;
  background: transparent; padding: 0 12px; border-radius: 8px; color: var(--on-surface); }
.menu button:hover { background: var(--box-grey); }
.menu button.danger { color: var(--rec-red); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 2px 8px;
  background: var(--chip-grey); color: var(--on-surface-variant); }
.badge.ok { background: var(--ok-container); color: var(--ok); }
.badge.rec { background: var(--rec-red-container); color: var(--rec-red); animation: blink 1.2s infinite; }
.badge.proc { background: var(--primary-container); color: var(--primary); }
.badge.wait { background: var(--warn-container); color: var(--warn-text); }
.badge.err { background: var(--rec-red-container); color: var(--rec-red); }
.badge.warn { background: var(--warn-container); color: var(--warn-text); }
@keyframes blink { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .badge.rec { animation: none; } }

.empty { text-align: center; color: var(--on-surface-variant); padding: 40px 16px; }
.error-banner { background: var(--rec-red-container); color: var(--rec-red); border-radius: var(--radius);
  padding: 10px 14px; }

dialog { border: none; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px));
  box-shadow: 0 12px 40px rgba(0,0,0,.25); color: var(--on-surface); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dialog-body h2 { font-size: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; color: var(--on-surface-variant); }
.field input[type=text], .field input[type=password] { min-height: 44px; border: 1px solid var(--divider);
  border-radius: var(--radius); padding: 0 12px; font: inherit; color: inherit; background: var(--surface); }
.field .helper { font-size: 12px; color: var(--on-surface-variant); }
.field .error { font-size: 13px; color: var(--rec-red); }
.lang-row { display: flex; gap: 8px; }
.lang-btn { flex: 1; min-height: 48px; border-radius: var(--radius); border: 1px solid var(--divider);
  background: var(--surface); color: var(--on-surface); font-weight: 500; }
.lang-btn[aria-pressed="true"] { background: var(--primary-container); border-color: var(--primary);
  color: var(--primary); font-weight: 700; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: #263238; color: #fff; border-radius: 10px; padding: 10px 16px; max-width: calc(100vw - 32px);
  opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }

@media (min-width: 900px) {
  .shell { grid-template-columns: 280px 1fr; }
  .sidebar { border-bottom: none; border-right: 1px solid var(--divider); position: sticky; top: 0;
    height: 100vh; }
  .filter-list { flex-direction: column; flex-wrap: nowrap; }
  .filter { border-radius: var(--radius); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 24px; }
}
@media (min-width: 1500px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------------------------------------------------------------- màn Ghi âm */
.record-view { max-width: 1100px; margin: 0 auto; padding: var(--gutter); display: flex; flex-direction: column; gap: 12px; }
.record-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.record-head h1 { font-size: 22px; overflow-wrap: anywhere; }
.rec-state { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 3px 10px; background: var(--chip-grey); }
.rec-state.recording { background: var(--rec-red-container); color: var(--rec-red); animation: blink 1.2s infinite; }
.rec-state.paused { background: var(--warn-container); color: var(--warn-text); }
.rec-state.saved { background: var(--ok-container); color: var(--ok); }
.record-main { display: grid; grid-template-columns: 1fr; gap: 12px; }
.record-panel { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.rec-timer { font-size: 56px; font-weight: 300; text-align: center; font-variant-numeric: tabular-nums; }
.level-label { font-size: 12px; color: var(--on-surface-variant); margin-bottom: 4px; }
.level-bar { height: 10px; background: var(--chip-grey); border-radius: 999px; overflow: hidden; }
.level-bar-fill { height: 100%; width: 0; background: var(--ok); transition: width .1s linear; }
.mic-note { font-size: 13px; border-radius: 8px; padding: 6px 10px; }
.mic-note.ok { background: var(--ok-container); color: var(--ok); }
.mic-note.warn { background: var(--warn-container); color: var(--warn-text); }
.rec-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.captions h3, .segment-list h3 { font-size: 14px; color: var(--on-surface-variant); margin-bottom: 6px; }
.caption-body { min-height: 160px; max-height: 320px; overflow-y: auto; background: var(--box-grey);
  border-radius: 8px; padding: 10px 12px; font-size: 17px; line-height: 1.55; overflow-wrap: anywhere; }
.caption-tentative { color: var(--on-surface-variant); font-style: italic; }
.caption-note { color: var(--on-surface-variant); font-size: 14px; }
.segment-list { display: flex; flex-direction: column; gap: 6px; }
.segment-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--divider); }
.segment-row .badge { margin-left: auto; }
.muted { color: var(--on-surface-variant); font-size: 13px; }
@media (min-width: 900px) { .record-main { grid-template-columns: 420px 1fr; } }

/* ---------------------------------------------------------------- Chọn đoạn / Xử lý / Kết quả */
.page { max-width: 1100px; margin: 0 auto; padding: var(--gutter); display: flex; flex-direction: column; gap: 12px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.page-head h1 { font-size: 22px; overflow-wrap: anywhere; }
.grow { flex: 1 1 auto; min-width: 0; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 12px; }
.panel { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.panel-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel h2 { font-size: 16px; }
.block { display: block; }
.segment-pick { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--divider);
  min-height: 48px; cursor: pointer; }
.segment-pick.skipped { opacity: .6; }
.segment-pick input, .option input { width: 20px; height: 20px; flex: none; }
.stat-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.option-label { font-size: 14px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.proc-badge-row { display: flex; align-items: center; gap: 10px; }
.level-bar-fill.proc { background: var(--primary); }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.step { display: flex; gap: 12px; }
.step-num { flex: none; width: 28px; height: 28px; border-radius: 999px; background: var(--chip-grey);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.step.done .step-num { background: var(--ok); color: #fff; }
.step.running .step-num { background: var(--primary); color: #fff; }
.step.stopped .step-num { background: var(--warn); color: #fff; }
.step-name { font-weight: 600; }
.step-status { font-size: 13px; margin-top: 2px; }
.step.running .step-status { color: var(--primary); }
.step.done .step-status { color: var(--ok); }
.preview h3 { font-size: 12px; letter-spacing: .04em; color: var(--on-surface-variant); margin-bottom: 6px; }
.preview { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 14px; }
.preview-body { max-height: 240px; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--divider); }
.tab { border: none; background: transparent; padding: 10px 16px; min-height: 44px; color: var(--on-surface-variant);
  border-bottom: 3px solid transparent; }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.prose, .transcript p { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 10px; }
.actions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.action { border: 1px solid var(--divider); border-radius: 10px; padding: 10px 12px; }
.action-text { font-weight: 600; overflow-wrap: anywhere; }
.hint.warn { background: var(--warn-container); color: var(--warn-text); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.export-wrap { position: relative; }
.export-wrap .menu { right: 0; top: 48px; }
.btn.danger-text { color: var(--rec-red); }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; } }

/* Thanh nhắc đang ghi âm khi rời màn Ghi âm */
.rec-pill { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 25; border: none;
  background: var(--rec-red); color: #fff; border-radius: 999px; padding: 10px 18px; min-height: 44px;
  max-width: calc(100vw - 24px); box-shadow: 0 6px 20px rgba(0,0,0,.25); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }

/* Màn đăng nhập toàn trang */
.login-screen { position: fixed; inset: 0; z-index: 50; background: var(--background); display: flex;
  align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--divider); border-radius: 16px;
  padding: 24px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 22px; }
.login-card .check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.login-card .check input { width: 18px; height: 18px; }
.login-card .error { min-height: 18px; }

/* Phiên bản kết quả và hộp thoại Xử lý lại */
.runs-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; justify-content: space-between; }
.runs-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 4px 12px; border-radius: 18px; border: 1px solid var(--divider);
  background: var(--surface); color: var(--on-surface); font-size: 13px; }
.chip.selected { background: var(--primary-container); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chip:disabled { opacity: .55; }
.runs-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.group { border: 1px solid var(--divider); border-radius: 10px; padding: 8px 12px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.group legend { font-size: 12px; font-weight: 600; color: var(--on-surface-variant); padding: 0 4px; }
.radio-row { display: flex; align-items: flex-start; gap: 8px; min-height: 32px; }
.radio-row input { margin-top: 4px; }
.field-row { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.select-field { min-height: 40px; border: 1px solid var(--divider); border-radius: 8px; padding: 0 8px; background: var(--surface); color: var(--on-surface); }
.full-only { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.full-only[hidden] { display: none; }

