:root {
  color-scheme: light;
  --paper: #fbf7ee;
  --ink: #1f2933;
  --muted: #697386;
  --line: #ded7c7;
  --blue: #1769aa;
  --blue-soft: #e8f2fb;
  --green: #2f7d59;
  --red: #b84545;
  --amber: #c17d1f;
  --white: #fffdf8;
  --shadow: 0 12px 32px rgba(46, 39, 25, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f6f2e8 0%, #eef6f4 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px calc(88px + env(safe-area-inset-bottom));
}

.topbar,
.session-head,
.panel-head,
.action-row,
.study-actions {
  display: flex;
  align-items: center;
}

.topbar,
.session-head,
.panel-head {
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.date-pill {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.view {
  display: none;
  margin-top: 20px;
}

.view.active {
  display: block;
}

.hero {
  display: grid;
  grid-template-columns: 1fr 108px;
  align-items: center;
  min-height: 148px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-copy p {
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.hero-copy strong {
  display: block;
  max-width: 340px;
  font-size: clamp(25px, 8vw, 38px);
  line-height: 1.08;
}

.hero-mark {
  width: 108px;
  height: 108px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stats-grid article,
.panel,
.word-card,
.word-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.9);
}

.stats-grid article {
  min-height: 82px;
  padding: 14px;
}

.stats-grid span,
.panel-head span,
.muted,
.part,
.scene,
dt,
.word-list small {
  color: var(--muted);
}

.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.action-row,
.study-actions {
  gap: 10px;
  margin-top: 16px;
}

.primary,
.secondary,
.danger {
  min-height: 48px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 800;
}

.primary {
  flex: 1;
  background: var(--blue);
  color: white;
}

.secondary {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
}

.danger {
  flex: 1;
  background: #fff1ee;
  color: var(--red);
  border: 1px solid #efc4bb;
}

.panel {
  margin-top: 14px;
  padding: 16px;
}

.panel h2 {
  margin-bottom: 8px;
}

.muted {
  margin-bottom: 0;
  font-size: 14px;
  line-height: 1.5;
}

.progress-track {
  height: 10px;
  margin: 12px 0 10px;
  border-radius: 999px;
  background: #e6ddce;
  overflow: hidden;
}

.progress-track div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--red));
  transition: width 0.2s ease;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 32px;
  line-height: 1;
}

.word-card {
  min-height: 470px;
  margin-top: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.scene {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  margin-bottom: 18px;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.word-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(36px, 13vw, 62px);
  line-height: 1;
}

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

.word-title-row h3 {
  min-width: 0;
}

.speak-btn {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}

.speak-btn:disabled {
  opacity: 0.45;
}

.part {
  margin: 8px 0 24px;
  font-weight: 700;
}

.meaning strong {
  display: block;
  margin-bottom: 16px;
  font-size: 24px;
  line-height: 1.25;
}

dl {
  margin: 0;
}

dl div {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

dt {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 800;
}

dd {
  margin: 0;
  line-height: 1.5;
}

blockquote {
  margin: 16px 0 0;
  padding: 14px;
  border-left: 4px solid var(--blue);
  background: #f3f8fb;
  border-radius: 8px;
}

blockquote p {
  margin-bottom: 8px;
  line-height: 1.5;
}

blockquote cite {
  color: var(--muted);
  font-style: normal;
}

.hidden {
  display: none !important;
}

#searchInput,
.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--white);
  color: var(--ink);
}

#searchInput {
  max-width: 230px;
}

.word-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.word-list article {
  padding: 14px;
}

.word-list h3 {
  margin: 0 0 6px;
  font-size: 19px;
}

.word-list p {
  margin-bottom: 8px;
  line-height: 1.42;
}

.field {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  font-weight: 800;
}

.danger-zone {
  border-color: #efc4bb;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(18px);
}

.tabbar button {
  min-height: 48px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tabbar button.active {
  background: var(--blue-soft);
  color: var(--blue);
}

@media (max-width: 430px) {
  .app-shell {
    padding-inline: 12px;
  }

  .hero {
    grid-template-columns: 1fr 82px;
    padding: 16px;
  }

  .hero-mark {
    width: 82px;
    height: 82px;
  }

  .panel-head {
    align-items: flex-start;
  }

  #searchInput {
    max-width: 170px;
  }

  .word-title-row {
    flex-direction: column;
  }

  .speak-btn {
    min-width: 92px;
  }
}
