:root {
  color-scheme: light;
  --ink: #1f2923;
  --muted: #69746d;
  --paper: #f4f0e7;
  --surface: #fffdf8;
  --green: #2f4b3c;
  --green-light: #dce7df;
  --rust: #b95d3f;
  --gold: #d6aa5c;
  --line: #d9d4ca;
  --shadow: 0 18px 45px rgba(31, 41, 35, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
html { min-width: 0; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); min-height: 100vh; overflow-x: hidden; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .22; background-image: radial-gradient(#7d786f 0.55px, transparent .55px); background-size: 7px 7px; }
main, .app-shell, #writerView, #adminView, .topbar > *, .panel, .hero-card, .entries-section { min-width: 0; }
button, input, textarea, select { font: inherit; }
button { max-width: 100%; cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 .45rem; color: var(--rust); font-size: .73rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
h1 { margin-bottom: 0; font-size: clamp(1.8rem, 5vw, 2.8rem); }
h2 { margin-bottom: .5rem; font-size: clamp(1.45rem, 3vw, 2rem); }
.intro, .muted, small { color: var(--muted); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: min(100%, 430px); padding: clamp(1.5rem, 6vw, 3.2rem); border: 1px solid var(--line); border-radius: 28px; background: rgba(255,253,248,.96); box-shadow: var(--shadow); }
form { display: grid; gap: 1rem; }
label { display: grid; gap: .42rem; font-size: .84rem; font-weight: 750; }
.remember-row { display: flex; align-items: center; gap: .6rem; font-weight: 600; }
.remember-row input { width: auto; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); padding: .78rem .9rem; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(47,75,60,.12); }
textarea { min-height: 105px; resize: vertical; line-height: 1.55; }
.transcript { min-height: 310px; }
.primary, .file-picker { border: 0; border-radius: 12px; padding: .82rem 1rem; background: var(--green); color: #fff; font-weight: 800; text-align: center; box-shadow: 0 6px 18px rgba(47,75,60,.18); }
.primary:hover, .file-picker:hover { background: #233b2e; }
.primary:disabled { opacity: .55; cursor: wait; }
.quiet { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .85rem; background: rgba(255,255,255,.66); color: var(--ink); }
.error { color: #a2352f; min-height: 1.2em; }
.app-shell { position: relative; width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 1rem 0 4rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 0 2rem; }
.user-actions { display: flex; align-items: center; gap: .75rem; }
.panel, .hero-card, .admin-inbox, .review-panel, .review-empty { background: rgba(255,253,248,.95); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 8px 24px rgba(31,41,35,.055); }
.hero-card { padding: clamp(1.4rem, 5vw, 3rem); text-align: center; background: linear-gradient(145deg, rgba(255,253,248,.98), rgba(226,233,222,.95)); }
.hero-card > p { color: var(--muted); }
.recorder { display: grid; justify-items: center; gap: .8rem; margin-top: 1.5rem; }
.recording-clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 1.1rem; }
.record-button { width: min(100%, 330px); display: flex; align-items: center; justify-content: center; gap: .8rem; border: 0; border-radius: 999px; padding: 1.05rem 1.25rem; background: var(--green); color: #fff; box-shadow: 0 10px 28px rgba(47,75,60,.24); }
.record-button span { width: 18px; height: 18px; border-radius: 50%; background: #ef765f; }
.record-button.recording { background: #79362d; }
.record-button.recording span { border-radius: 3px; }
audio { width: 100%; max-width: 540px; }
.upload-panel { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1.5rem; margin-top: 1rem; padding: 1.4rem; }
.upload-panel h2 { font-size: 1.35rem; }
.upload-panel p { margin-bottom: 0; }
.file-picker input { display: none; }
#detailsPanel { margin-top: 1rem; padding: 1.4rem; }
.progress { height: 6px; overflow: hidden; border-radius: 99px; background: var(--line); }
.progress span { display: block; width: 35%; height: 100%; background: var(--gold); animation: loading 1s infinite ease-in-out alternate; }
@keyframes loading { to { transform: translateX(185%); } }
.entries-section { margin-top: 2.3rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.entry-list { display: grid; gap: .85rem; }
.entry-card { padding: 1.2rem; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,253,248,.88); }
.entry-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.entry-card h3 { margin-bottom: .25rem; }
.entry-card audio { margin-top: .8rem; }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: .3rem .55rem; background: #e8e4dc; color: #5f625f; font-size: .7rem; font-weight: 850; white-space: nowrap; }
.status-aprobado { background: #d9eadc; color: #285c35; }
.status-recibido, .status-pendiente_revision { background: #fae9c7; color: #795512; }
.status-rechazado, .status-error { background: #f5d9d4; color: #843a32; }
.status-transcribiendo, .status-codex_en_curso { background: #d9e5ef; color: #28506f; }
.status-transcrito, .status-enviado_jeijoland { background: #e5dfef; color: #594275; }
.status-procesado { background: #d9eadc; color: #285c35; }
.status-error_transcripcion, .status-error_codex { background: #f5d9d4; color: #843a32; }
.memory-id { margin-bottom: .25rem; color: var(--rust); font-size: .76rem; font-weight: 800; letter-spacing: .06em; }
.state-help { color: var(--muted); }
.processed-summary { padding: .9rem 1rem; border-left: 3px solid var(--green); background: var(--green-light); line-height: 1.5; }
.transcription-summary { display: grid; grid-template-columns: 1.7fr .65fr .65fr; gap: 1rem; align-items: center; margin-bottom: 1rem; padding: 1rem 1.2rem; }
.transcription-summary > div { display: grid; gap: .2rem; }
.transcription-summary span { font: 500 1.35rem Georgia, serif; }
.transcription-summary small { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.admin-settings { margin-bottom: 1rem; padding: 0; overflow: hidden; }
.admin-settings summary { display: flex; align-items: center; justify-content: space-between; padding: 1.05rem 1.2rem; cursor: pointer; list-style: none; }
.admin-settings summary::-webkit-details-marker { display: none; }
.admin-settings summary > span:first-child { display: grid; }
.admin-settings[open] .summary-action { font-size: 0; }
.admin-settings[open] .summary-action::after { content: "Cerrar"; font-size: .8rem; }
.settings-content { display: grid; grid-template-columns: 1.1fr .9fr; gap: 1.5rem; padding: 1.2rem; border-top: 1px solid var(--line); }
.settings-content h3 { margin-bottom: .55rem; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.api-settings { padding: 1rem; border-radius: 16px; background: #f0ece3; }
.settings-facts { display: grid; gap: .7rem; margin: 1rem 0 0; }
.settings-facts div { display: grid; gap: .2rem; }
.settings-facts dt { color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.settings-facts dd { margin: 0; overflow-wrap: anywhere; }
.workflow-actions { display: flex; align-items: center; gap: 1rem; margin: 0 0 1.4rem; }
.workflow-actions p { margin: 0; color: var(--muted); }
.admin-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-bottom: 1rem; }
.admin-upload { margin-bottom: 1rem; padding: 0; overflow: hidden; }
.admin-upload summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.05rem 1.2rem; cursor: pointer; list-style: none; }
.admin-upload summary::-webkit-details-marker { display: none; }
.admin-upload summary > span:first-child { display: grid; }
.admin-upload summary .eyebrow { margin-bottom: .2rem; }
.summary-action { color: var(--green); font-size: .8rem; font-weight: 800; }
.admin-upload[open] .summary-action { font-size: 0; }
.admin-upload[open] .summary-action::after { content: "Cerrar"; font-size: .8rem; }
.admin-upload form { padding: 0 1.2rem 1.2rem; border-top: 1px solid var(--line); }
.admin-recorder { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: .8rem; padding-top: 1rem; }
.admin-recorder audio { min-width: 180px; }
.compact-record { width: auto; padding: .75rem 1rem; }
.or-divider { display: flex; align-items: center; gap: .8rem; margin: .2rem 0; color: var(--muted); font-size: .8rem; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.admin-upload-grid { display: grid; grid-template-columns: minmax(240px, .8fr) minmax(260px, 1.2fr); gap: 1rem; padding-top: 1rem; }
.admin-upload .file-picker { display: inline-block; width: fit-content; margin-top: .1rem; }
.admin-upload-actions { display: flex; align-items: center; gap: 1rem; }
.admin-upload-actions p { margin: 0; }
.admin-summary div { display: grid; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,253,248,.9); }
.admin-summary span { font: 500 2rem Georgia, serif; }
.admin-summary small { text-transform: uppercase; letter-spacing: .08em; }
.admin-layout { display: grid; grid-template-columns: minmax(290px, .75fr) minmax(0, 1.35fr); gap: 1rem; align-items: start; }
.admin-inbox { padding: 1rem; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
.filter-label { margin: .7rem 0 1rem; }
.entry-row { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .85rem; border: 1px solid transparent; border-radius: 12px; background: transparent; text-align: left; }
.entry-row:hover, .entry-row.selected { background: var(--green-light); border-color: #bed0c2; }
.entry-row span:first-child { display: grid; gap: .18rem; min-width: 0; }
.entry-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-panel, .review-empty { padding: clamp(1.2rem, 4vw, 2rem); }
.review-empty { text-align: center; padding-block: 5rem; color: var(--muted); }
.review-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.review-panel audio { margin: .8rem 0 1.2rem; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin: 0 0 1.4rem; }
.facts div { min-width: 0; padding: .7rem; border-radius: 10px; background: #f0ece3; }
.facts dt { color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.facts dd { overflow: hidden; margin: .2rem 0 0; text-overflow: ellipsis; white-space: nowrap; }
.empty-list { padding: 1.8rem 1rem; color: var(--muted); text-align: center; }
@media (max-width: 760px) {
  .app-shell { width: 100%; padding: .5rem .5rem calc(4rem + env(safe-area-inset-bottom)); }
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: .75rem; padding: .8rem .25rem 1.25rem; }
  .topbar h1 { font-size: clamp(1.75rem, 9vw, 2.25rem); line-height: 1.05; overflow-wrap: anywhere; }
  .topbar .eyebrow { font-size: .65rem; letter-spacing: .1em; }
  .user-actions { flex-direction: row; align-items: center; gap: .45rem; min-width: 0; }
  .user-actions span { max-width: 5.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hero-card { padding: 1.4rem 1rem; border-radius: 18px; }
  .hero-card > p { margin-inline: auto; max-width: 32rem; line-height: 1.5; }
  .record-button { width: 100%; min-width: 0; padding-inline: 1rem; }
  .record-button strong { min-width: 0; overflow-wrap: anywhere; }
  .panel, .admin-inbox, .review-panel { border-radius: 18px; }
  .upload-panel { gap: 1rem; padding: 1.15rem; }
  .upload-panel h2, .section-heading h2 { overflow-wrap: anywhere; }
  .upload-panel, .admin-layout, .admin-upload-grid, .transcription-summary, .settings-content, .settings-grid { grid-template-columns: 1fr; }
  .workflow-actions { align-items: stretch; flex-direction: column; }
  .admin-recorder { grid-template-columns: 1fr auto; }
  .admin-recorder audio { grid-column: 1 / -1; }
  .file-picker { width: 100%; }
  .admin-inbox { position: static; max-height: none; }
  .facts { grid-template-columns: 1fr; }
  .review-empty { display: none; }
}

@media (max-width: 420px) {
  .topbar { grid-template-columns: 1fr; }
  .user-actions { justify-content: space-between; width: 100%; }
  .hero-card h2 { font-size: 1.7rem; }
  .record-button { gap: .65rem; padding: .95rem .8rem; }
  .record-button strong { font-size: .95rem; }
  .upload-panel h2 { font-size: 1.25rem; }
  .section-heading, .entry-card-head, .review-header, .admin-upload-actions { align-items: flex-start; flex-wrap: wrap; }
  .admin-recorder { grid-template-columns: 1fr; }
  .admin-recorder audio { min-width: 0; }
  .admin-summary { grid-template-columns: 1fr; }
  .admin-upload summary, .admin-settings summary { gap: .75rem; }
}
