*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

:root {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --primary: #2d5a4e;
  --primary-hover: #3d7a68;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --border: #e0ddd6;
  --radius: 12px;
  --red: #c0392b;
}

html {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
}

/* Schermen */

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
}

.screen.active {
  display: flex;
}

/* Header */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: -0.01em;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--primary);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn svg { width: 20px; height: 20px; }

/* Cheatsheet */

.cheatsheet {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 42px;
}

.cs-item {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  background: var(--primary);
  color: #fff;
  border-radius: 4px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.cs-item.cs-opt {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  opacity: 0.65;
}

/* Opnemen */

.opnemen-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 20px 28px;
  gap: 28px;
}

.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.record-btn {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(45, 90, 78, 0.28);
  transition: transform 0.12s, box-shadow 0.12s, background 0.18s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.record-btn:hover { transform: scale(1.04); }
.record-btn:active { transform: scale(0.96); }

.record-btn.recording {
  background: var(--red);
  box-shadow: 0 4px 20px rgba(192, 57, 43, 0.3);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(192, 57, 43, 0.3); }
  50%       { box-shadow: 0 6px 32px rgba(192, 57, 43, 0.55); }
}

.record-icon {
  width: 30px;
  height: 30px;
  background: #fff;
  border-radius: 50%;
  transition: border-radius 0.18s, width 0.18s, height 0.18s;
}

.record-btn.recording .record-icon {
  border-radius: 5px;
  width: 22px;
  height: 22px;
}

.timer {
  font-size: 2.4rem;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--text);
  line-height: 1;
}

.status-tekst {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.opname-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.75;
  text-align: center;
  margin-top: 2px;
}

/* Scheider */

.divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Plakken */

.paste-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paste-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.paste-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  line-height: 1.5;
}
.paste-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Verwerken */

.verwerken-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px 20px;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.verwerken-tekst {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Resultaat */

.resultaat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 24px;
  gap: 10px;
}

.resultaat-waarschuwing {
  padding: 10px 14px;
  background: #fef9e7;
  border: 1px solid #f0c040;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: #7a4f00;
  line-height: 1.4;
}

.resultaat-datum {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: capitalize;
  padding: 2px 0;
}

.verslag-tekst {
  flex: 1;
  width: 100%;
  min-height: 260px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.7;
  background: var(--surface);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  cursor: text;
}
.verslag-tekst:focus {
  outline: none;
  border-color: var(--primary);
}

.punt-twijfel {
  background: #fef3c7;
  border-radius: 3px;
  cursor: pointer;
  padding: 0 1px;
}
.punt-twijfel:hover { background: #fcd34d; }

.twijfel-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.13);
  z-index: 200;
  min-width: 190px;
  max-width: calc(100vw - 16px);
  overflow: hidden;
}
.twijfel-opties {
  list-style: none;
  padding: 4px 0;
  margin: 0;
}
.twijfel-optie {
  padding: 11px 16px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text);
  line-height: 1.3;
}
.twijfel-optie:hover { background: var(--bg); }
.twijfel-scheiding {
  border-top: 1px solid var(--border);
  margin: 3px 0;
}
.twijfel-weg { color: var(--text-muted); }

.twijfel-zoek-wrapper {
  padding: 7px 10px 8px;
  border-top: 1px solid var(--border);
}
.twijfel-zoek-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.88rem;
  background: var(--bg);
  color: var(--text);
}
.twijfel-zoek-input:focus {
  outline: none;
  border-color: var(--primary);
}

.resultaat-knoppen {
  display: flex;
  gap: 10px;
}

/* Transcript */

.transcript-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 14px;
}

.transcript-tekst {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Instellingen */

.instellingen-main {
  flex: 1;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow-y: auto;
}

.inst-sectie h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.inst-uitleg {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.inst-uitleg-mt { margin-top: 12px; display: block; }

.stijlvoorbeeld-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.82rem;
  line-height: 1.55;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
}
.stijlvoorbeeld-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Kopjes */

.kopjes-lijst {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.kopje-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 10px;
}

.kopje-hoofd {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0; /* laat het flex-item krimpen tot binnen zijn ouder */
}

.kopje-volgorde {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0; /* nooit inkrimpen */
}

.icon-btn-sm {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  width: 22px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text-muted);
  line-height: 1;
  padding: 0;
}
.icon-btn-sm:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
}
.icon-btn-sm:disabled {
  opacity: 0.2;
  cursor: default;
}

.kopje-naam {
  flex: 1 1 0; /* groeit én krimpt vrijelijk */
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}
.kopje-naam:focus {
  outline: none;
  border-color: var(--primary);
}

.kopje-opt-label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0; /* nooit inkrimpen */
}

.kopje-beschrijving {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg);
}
.kopje-beschrijving:focus {
  outline: none;
  border-color: var(--primary);
  color: var(--text);
}
.kopje-beschrijving::placeholder { opacity: 0.6; }

.kopje-del {
  flex-shrink: 0; /* altijd zichtbaar, nooit inkrimpen */
  color: var(--red) !important;
  opacity: 0.7;
}
.kopje-del:hover {
  background: #fdf2f0 !important;
  opacity: 1;
}

.btn-add {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 9px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--primary);
  cursor: pointer;
  width: 100%;
  transition: background 0.12s;
}
.btn-add:hover { background: var(--bg); }

/* Radio */

.radio-groep {
  display: flex;
  gap: 24px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  user-select: none;
}

/* Woordenlijst */

.woordenlijst-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.88rem;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  line-height: 1.6;
}
.woordenlijst-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Meridianen */

.meridiatabeel-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.88rem;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  line-height: 1.6;
}
.meridiatabeel-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Code */

.code-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  letter-spacing: 0.05em;
}
.code-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Knoppen */

.btn-primary {
  flex: 1;
  padding: 13px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  touch-action: manipulation;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary.btn-full { flex: none; width: 100%; }

.btn-secondary {
  flex: 1;
  padding: 13px 20px;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  touch-action: manipulation;
}
.btn-secondary:hover { background: var(--bg); }

/* Kopieer bevestiging */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 199;
}
.kopieer-bevestig {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 48px);
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.kopieer-bevestig-tekst {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.45;
}
.kopieer-bevestig-knoppen {
  display: flex;
  gap: 10px;
}

/* Veilige zones voor notch/thuisbalk */
@supports (padding: max(0px)) {
  .app-header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .instellingen-main,
  .resultaat-main,
  .opnemen-main {
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }
}
