* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --panel: #161618;
  --panel-2: #222226;
  --text: #f6f6f7;
  --muted: #a9a9b2;
  --line: #34343a;
  --accent: #ffffff;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

button,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  padding:
    max(12px, env(safe-area-inset-top))
    16px
    max(14px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.topbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 12px;
}

.icon-button {
  border: 0;
  border-radius: 14px;
  min-width: 44px;
  min-height: 44px;
  background: var(--panel);
  color: var(--text);
  font-size: 24px;
}

.progress-wrap {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 180ms ease;
}

.card {
  position: relative;
  overflow: hidden;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
  touch-action: pan-y;
}

.page-content {
  height: 100%;
  min-height: 520px;
}

.page {
  min-height: 100%;
  height: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fade-in 150ms ease;
}

.page.image-page {
  padding: 0;
  background: #101012;
}

.card-image {
  width: 100%;
  height: 100%;
  min-height: 520px;
  object-fit: cover;
  display: block;
}

.image-overlay-page {
  position: relative;
  padding: 0;
  overflow: hidden;
}

.image-overlay-page .card-image {
  position: absolute;
  inset: 0;
}

.image-overlay {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 520px;
  padding: 36px 24px 56px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(
    to bottom,
    rgb(0 0 0 / 4%),
    rgb(0 0 0 / 12%) 46%,
    rgb(0 0 0 / 88%)
  );
  text-shadow: 0 2px 16px rgb(0 0 0 / 70%);
}

.word {
  margin: 0;
  font-size: clamp(42px, 10vw, 76px);
  line-height: 1;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}

.pronunciation {
  margin: 14px 0 0;
  color: #e3e3e7;
  font-size: 18px;
}

.example {
  margin: 0;
  max-width: 680px;
  font-size: clamp(25px, 5.8vw, 44px);
  line-height: 1.25;
  font-weight: 700;
}

.detail-page {
  align-items: stretch;
  justify-content: flex-start;
  background: #000;
  overflow-y: auto;
}

.detail-title {
  margin: 8px 0 6px;
  font-size: clamp(36px, 9vw, 64px);
  letter-spacing: -0.035em;
}

.detail-pronunciation {
  margin: 0 0 24px;
  color: var(--muted);
}

.detail-block {
  padding: 18px 0;
  border-top: 1px solid #2b2b2f;
}

.detail-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-value {
  margin: 0;
  font-size: 20px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.page-dots {
  position: absolute;
  right: 0;
  bottom: 16px;
  left: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 7px;
  pointer-events: none;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: rgb(255 255 255 / 36%);
}

.dot.active {
  width: 20px;
  background: #fff;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.control-button {
  min-height: 50px;
  border: 0;
  border-radius: 16px;
  font-weight: 800;
}

.control-button.primary {
  background: #fff;
  color: #080809;
}

.control-button.secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}

.counter {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

dialog {
  width: min(92vw, 520px);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop {
  background: rgb(0 0 0 / 70%);
  backdrop-filter: blur(6px);
}

.settings-panel {
  padding: 22px;
}

.settings-title-row,
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-title-row h2 {
  margin: 0;
}

.setting-row {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
}

.danger-button {
  width: 100%;
  margin-top: 12px;
  min-height: 48px;
  border: 1px solid #6b2f35;
  border-radius: 14px;
  background: #32171a;
  color: #ffb9bf;
  font-weight: 800;
}

.error {
  padding: 30px;
  color: #ffb9bf;
  line-height: 1.6;
}

@keyframes fade-in {
  from {
    opacity: 0.5;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 700px) {
  .page-content,
  .card-image,
  .image-overlay {
    min-height: 650px;
  }
}
