:root {
  color-scheme: light;
  --app-bg: #e9eef3;
  --surface: #f8fafc;
  --card: #ffffff;
  --soft: #e3e8ee;
  --soft-strong: #d7dee7;
  --text: #0f1720;
  --muted: #6b747f;
  --border: #c4cbd4;
  --accent: #0875d1;
  --accent-soft: #d8ebfb;
  --green: #07863a;
  --green-soft: #d6e8df;
  --amber: #b26b00;
  --amber-soft: #ece3d5;
  --red: #bb2834;
  --red-soft: #ead9dc;
  --shadow: 0 10px 24px rgba(15, 23, 32, 0.12);
  --radius: 8px;
  --tap: 44px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--app-bg);
  color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--text);
  padding: 10px 14px;
  font-weight: 760;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled,
.is-disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 117, 209, 0.18);
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--app-bg);
  position: relative;
  padding: 0 0 calc(86px + env(safe-area-inset-bottom));
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.96);
  backdrop-filter: blur(16px);
}

.app-topbar h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.1;
  font-weight: 860;
}

.app-topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  min-width: var(--tap);
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--text);
}

.icon,
.tab-icon,
.feature-icon {
  width: 22px;
  height: 22px;
  display: inline-block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.feature-icon {
  width: 30px;
  height: 30px;
}

.page {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.page-header {
  display: grid;
  gap: 4px;
  padding: 2px 0 8px;
}

.page-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  font-weight: 880;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 620;
}

.back-button {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 18px;
  font-weight: 720;
}

.back-button .icon {
  width: 20px;
  height: 20px;
}

.section-label {
  margin: 8px 0 -4px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 850;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.card,
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card-soft {
  background: var(--soft);
}

.hero-card {
  display: grid;
  gap: 14px;
}

.hero-row,
.metric-row,
.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.metric-label,
.muted {
  color: var(--muted);
}

.metric-label {
  font-size: 15px;
  font-weight: 720;
}

.metric-value {
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
}

.metric-caption {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.progress-track,
.status-track {
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft-strong);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.status-track {
  display: flex;
  gap: 1px;
  background: var(--soft-strong);
}

.status-segment {
  min-width: 3px;
  height: 100%;
}

.status-known {
  background: var(--green);
}

.status-active {
  background: var(--accent);
}

.status-passive {
  background: #68727e;
}

.status-confused {
  background: var(--amber);
}

.status-unknown {
  background: #aeb7c1;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 58px;
  font-size: 18px;
}

.action-button-primary,
button.primary,
.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.action-button-secondary {
  background: var(--soft);
}

.action-grid,
.feature-grid,
.stats-grid,
.button-row,
.search-row,
.stack {
  display: grid;
  gap: 10px;
}

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

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

.button-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.search-row {
  grid-template-columns: 1fr auto;
}

.feature-card,
.stat-tile {
  display: grid;
  align-content: center;
  min-height: 98px;
  border-radius: var(--radius);
  text-align: left;
}

.feature-card {
  justify-items: start;
  gap: 7px;
  padding: 16px;
}

.feature-title {
  font-size: 18px;
  line-height: 1.08;
  font-weight: 860;
}

.feature-subtitle {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.18;
  font-weight: 650;
}

.stat-tile {
  justify-items: center;
  gap: 3px;
  padding: 12px 8px;
  background: var(--soft);
  border: 0;
}

.stat-number {
  font-size: 26px;
  line-height: 1;
  font-weight: 900;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
  text-align: center;
}

.text-green {
  color: var(--green);
}

.text-blue {
  color: var(--accent);
}

.text-amber {
  color: var(--amber);
}

.text-red {
  color: var(--red);
}

.pill,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: var(--radius);
  background: var(--soft-strong);
  color: #3f4852;
  padding: 4px 9px;
  font-size: 13px;
  font-weight: 780;
  white-space: nowrap;
}

.chip-blue {
  background: var(--accent-soft);
  color: var(--accent);
}

.chip-green {
  background: var(--green-soft);
  color: var(--green);
}

.chip-amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.alert {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  border-radius: var(--radius);
  padding: 14px;
  font-weight: 720;
}

.alert-info {
  border: 1px solid #8cc5f4;
  background: #d6e9fa;
  color: var(--accent);
}

.alert-warning {
  border: 1px solid #dfc174;
  background: #ebe4d8;
  color: var(--amber);
}

.alert-error,
.error {
  border: 1px solid #df9aa3;
  background: var(--red-soft);
  color: var(--red);
}

.list-card {
  display: grid;
  gap: 10px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #3d4650;
  font-size: 20px;
  font-weight: 650;
}

.list-row strong {
  color: var(--text);
  font-weight: 880;
}

.hebrew {
  direction: rtl;
  unicode-bidi: isolate;
  font-size: 48px;
  line-height: 1.12;
  font-weight: 900;
  text-align: center;
  margin: 10px 0 2px;
}

.hebrew-small {
  direction: rtl;
  unicode-bidi: isolate;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 850;
  text-align: right;
}

.transcription {
  color: #4b5560;
  font-size: 18px;
  font-weight: 680;
  text-align: center;
}

.practice-card {
  display: grid;
  gap: 16px;
  text-align: center;
}

.answer-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--soft);
}

.answer-main {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 900;
}

.examples {
  color: #3f4852;
  font-size: 17px;
  font-weight: 620;
}

.grade {
  min-height: 58px;
  padding: 8px 6px;
  line-height: 1.08;
  font-size: 16px;
}

.grade span {
  font-size: 12px;
  font-weight: 780;
}

.grade-again {
  background: var(--red-soft);
  color: var(--red);
  border-color: transparent;
}

.grade-hard {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: transparent;
}

.grade-good {
  background: var(--green-soft);
  color: var(--green);
  border-color: transparent;
}

.grade-easy {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.result,
.stats {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #3f4852;
  font-weight: 620;
}

.preview-list {
  display: grid;
  gap: 0;
  margin: 0 -16px -16px;
  border-top: 1px solid var(--border);
}

.preview-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.form-label {
  display: grid;
  gap: 7px;
  color: #3f4852;
  font-weight: 760;
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  width: min(100%, 430px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.97);
  backdrop-filter: blur(16px);
}

.tab-item {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 54px;
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tab-icon {
  width: 26px;
  height: 26px;
  stroke-width: 2.1;
}

.tab-item.is-active {
  color: var(--accent);
}

.empty-state,
.loading-state {
  display: grid;
  gap: 14px;
  min-height: 52dvh;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.empty-state .icon {
  width: 54px;
  height: 54px;
  stroke-width: 1.8;
}

.empty-state h2 {
  margin: 6px 0 0;
  font-size: 24px;
  font-weight: 900;
}

.empty-state p {
  margin: 0;
  max-width: 330px;
  color: #3f4852;
  font-size: 18px;
  font-weight: 620;
}

[hidden] {
  display: none !important;
}

@media (max-width: 380px) {
  .page {
    padding: 14px;
  }

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

  .hebrew {
    font-size: 42px;
  }

  .feature-title,
  .action-button {
    font-size: 17px;
  }
}

@media (max-width: 340px) {
  .action-grid,
  .feature-grid,
  .search-row {
    grid-template-columns: 1fr;
  }

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