:root {
  --bg: #f4efe6;
  --bg-accent: linear-gradient(135deg, rgba(24, 109, 78, 0.12), rgba(214, 156, 72, 0.18));
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --text: #17261f;
  --muted: #5e7068;
  --primary: #176d4e;
  --primary-dark: #11543c;
  --secondary: #d89c48;
  --danger: #b54242;
  --border: rgba(23, 38, 31, 0.12);
  --shadow: 0 18px 50px rgba(23, 38, 31, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  --font-main: "IBM Plex Sans", "Segoe UI", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-main);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(214, 156, 72, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(23, 109, 78, 0.14), transparent 25%),
    var(--bg);
}

.shell {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.admin-shell {
  width: min(100%, 1200px);
}

.card {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.hero {
  background: var(--bg-accent), var(--surface-strong);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
}

h1,
h2,
p {
  margin-top: 0;
}

.lead {
  color: var(--muted);
  max-width: 56ch;
}

.stack {
  display: grid;
  gap: 16px;
}

.compact {
  gap: 12px;
}

.hidden {
  display: none !important;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: auto;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(23, 38, 31, 0.16);
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.helper-text {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button:not(:disabled):hover {
  transform: translateY(-1px);
}

.primary {
  background: var(--primary);
  color: #fff;
}

.secondary {
  background: rgba(216, 156, 72, 0.16);
  color: var(--text);
}

.ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid rgba(23, 109, 78, 0.2);
}

.grid-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.full {
  grid-column: 1 / -1;
}

.toolbar,
.toolbar-actions,
.recorder-grid,
.meta-row,
.progress-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.progress-card,
.sentence-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(23, 38, 31, 0.08);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.progress-bar {
  margin-top: 10px;
  background: rgba(23, 38, 31, 0.08);
  border-radius: 999px;
  overflow: hidden;
  height: 10px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.2s ease;
}

.badge {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 12px;
  background: rgba(23, 109, 78, 0.1);
  color: var(--primary-dark);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.sentence-text {
  font-size: clamp(1.3rem, 4vw, 2rem);
  line-height: 1.55;
  margin-bottom: 0;
}

.sentence-text,
.inline-sentence {
  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
}

.sentence-text.is-rtl,
.inline-sentence.is-rtl {
  direction: rtl;
}

.sentence-text.is-ltr,
.inline-sentence.is-ltr {
  direction: ltr;
}

.sentence-text.is-mixed,
.inline-sentence.is-mixed {
  direction: rtl;
  unicode-bidi: plaintext;
}

.inline-sentence {
  display: inline-block;
  max-width: 100%;
}

.audio-player {
  width: 100%;
}

.message {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  background: rgba(23, 109, 78, 0.1);
  color: var(--primary-dark);
  border: 1px solid rgba(23, 109, 78, 0.16);
  position: sticky;
  top: 10px;
  z-index: 10;
}

.message.error {
  background: rgba(181, 66, 66, 0.12);
  color: var(--danger);
  border-color: rgba(181, 66, 66, 0.18);
}

.muted {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(23, 38, 31, 0.08);
}

thead th {
  font-size: 0.85rem;
  color: var(--muted);
}

.status-select,
.review-input {
  min-width: 140px;
}

.auth-grid,
.stats-grid {
  display: grid;
  gap: 16px;
}

#auth-section {
  width: min(100%, 1180px);
  margin-inline: auto;
  align-items: start;
}

#auth-section > .card {
  min-width: 0;
}

#auth-section .stack.compact,
#auth-section .grid-form {
  align-content: start;
}

.auth-card {
  position: relative;
  overflow: hidden;
  height: 100%;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, rgba(23, 109, 78, 0.88), rgba(216, 156, 72, 0.82));
}

.auth-card-header {
  display: grid;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(23, 38, 31, 0.08);
}

.auth-card-header > * {
  margin-bottom: 0;
}

.auth-card-caption {
  color: var(--muted);
  max-width: 48ch;
}

.auth-form {
  max-width: 440px;
}

.register-form {
  gap: 16px 18px;
}

.participant-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
}

.compact-text {
  margin-bottom: 0;
}

.stat-card {
  min-height: 132px;
}

.compact-card {
  min-height: unset;
}

.big-number {
  display: block;
  font-size: 2rem;
  margin-top: 8px;
}

.mode-switch {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  background: rgba(23, 38, 31, 0.06);
  border-radius: 999px;
  width: fit-content;
}

.tab-button {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
}

.tab-button.active {
  background: var(--surface-strong);
  color: var(--primary-dark);
  box-shadow: 0 8px 24px rgba(23, 38, 31, 0.08);
}

.badge-row,
.action-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(23, 38, 31, 0.08);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
}

.pill.warning {
  background: rgba(216, 156, 72, 0.2);
}

.pill.success {
  background: rgba(23, 109, 78, 0.16);
  color: var(--primary-dark);
}

.pill.danger {
  background: rgba(181, 66, 66, 0.16);
  color: var(--danger);
}

.accent {
  background: linear-gradient(90deg, var(--secondary), var(--primary));
}

.callout-list {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: rgba(216, 156, 72, 0.08);
  border: 1px solid rgba(216, 156, 72, 0.18);
  border-radius: var(--radius-sm);
}
.sentence-card .badge-row,
.callout-item .badge-row {
  direction: ltr;
}

.callout-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.callout-item {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(23, 38, 31, 0.08);
}

.callout-item .inline-sentence,
td .inline-sentence {
  display: block;
}

.callout-item p:last-child {
  margin-bottom: 0;
}

.tip-grid {
  display: grid;
  gap: 12px;
}

.tip-card,
.status-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(23, 38, 31, 0.08);
  background: rgba(255, 255, 255, 0.76);
}

.accent-card {
  background: linear-gradient(135deg, rgba(216, 156, 72, 0.14), rgba(23, 109, 78, 0.08));
}

.tip-card h3,
.status-card strong {
  margin: 0 0 8px;
}

.tip-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.status-card p {
  margin-bottom: 0;
}

.empty-state {
  padding: 20px;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(23, 38, 31, 0.18);
  background: rgba(255, 255, 255, 0.56);
}

.empty-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.danger-soft {
  background: rgba(181, 66, 66, 0.14);
  color: var(--danger);
}

.plain-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding-left: 18px;
}

.plain-list li {
  display: grid;
  gap: 4px;
}

.block-link {
  display: inline-block;
  margin-top: 8px;
}

.narrow-form {
  width: min(100%, 420px);
}

details summary {
  cursor: pointer;
  color: var(--primary-dark);
  font-weight: 700;
}

@media (min-width: 720px) {
  .shell {
    padding: 32px 24px 56px;
  }

  .card {
    padding: 24px;
  }

  .grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-grid,
  .stats-grid,
  .tip-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 980px) {
  #auth-section {
    grid-template-columns: minmax(360px, 0.88fr) minmax(560px, 1.12fr);
    gap: 24px;
  }

  #auth-section > .card {
    padding: 30px;
  }

  .auth-card-login {
    position: sticky;
    top: 24px;
  }

  .auth-card-register {
    min-height: 100%;
  }
}

@media (max-width: 719px) {
  body {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .toolbar,
  .toolbar-actions,
  .meta-row,
  .progress-head,
  .badge-row,
  .action-row {
    align-items: stretch;
  }

  .mode-switch {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .tab-button {
    width: 100%;
  }

  .recorder-grid,
  .action-row,
  .empty-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .recorder-grid .button,
  .action-row .button,
  .empty-actions .button,
  .toolbar .button,
  .toolbar-actions .button {
    width: 100%;
  }

  .sentence-text {
    font-size: clamp(1.15rem, 5vw, 1.5rem);
  }

  .card {
    padding: 18px;
  }

  #auth-section {
    gap: 14px;
  }

  #auth-section .button,
  #auth-section input,
  #auth-section select,
  #auth-section textarea {
    width: 100%;
  }
}
