/* Legacy Kindle browsers get this simple block layout first. */
* {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

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

html {
  background: #f4f1e8;
}

body {
  margin: 0;
  background: #f4f1e8;
  color: #111;
  font-family: Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 18px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
}

main,
section {
  display: block;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 4px 6px 6px 4px;
}

.panel {
  border: 3px solid #1f1f1f;
  border-radius: 24px;
  background: #f4f1e8;
  box-shadow: 3px 3px 0 #1a1a1a;
}

.guide {
  position: fixed;
  z-index: 10;
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  width: calc(100% - 28px);
  max-width: 720px;
  max-height: 92vh;
  max-height: calc(100vh - 28px);
  margin: 0;
  padding: 18px;
  overflow: auto;
  color: #111;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}

.guide[open] {
  display: block;
}

.guide::backdrop {
  background: rgba(244, 241, 232, 0.92);
}

.guide-layout {
  margin-bottom: 18px;
}

.eyebrow,
.tiny-label {
  margin: 0 0 6px;
  color: #6c665b;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: 52px;
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.intro {
  max-width: 31rem;
  margin-bottom: 0;
  color: #312f2b;
  font-size: 1.1rem;
}

.daily-mark {
  width: 92px;
  height: 92px;
  margin: 0 0 12px auto;
  border: 3px solid #1f1f1f;
  border-radius: 50%;
  background: #ded8c8;
  text-align: center;
}

.daily-mark span {
  display: block;
  padding-top: 16px;
  font-size: 3rem;
  font-weight: 900;
  line-height: 0.8;
}

.daily-mark small {
  display: block;
  margin-top: 4px;
  color: #6c665b;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.learning-card {
  position: relative;
  overflow: visible;
}

.lesson-toolbar {
  position: relative;
  overflow: hidden;
  border-bottom: 3px solid #1f1f1f;
  padding: 5px 6px;
  white-space: nowrap;
  font-weight: 900;
}

.day-select-button {
  display: inline-block;
  min-width: 136px;
  min-height: 34px;
  margin: 0 4px 0 0;
  border: 3px solid #1f1f1f;
  border-radius: 14px;
  padding: 3px 10px;
  background: #faf7ee;
  color: #111;
  cursor: pointer;
  font-weight: 900;
  line-height: 1.05;
  text-align: left;
  vertical-align: middle;
}

.day-title,
.day-progress {
  display: block;
}

.day-title {
  font-size: 0.98rem;
}

.day-progress {
  color: #6c665b;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.day-arrow,
.day-page-button,
.day-cell {
  display: inline-block;
  min-width: 38px;
  min-height: 34px;
  margin: 0 2px;
  border: 3px solid #1f1f1f;
  border-radius: 50%;
  padding: 0;
  background: #faf7ee;
  color: #111;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 28px;
  text-align: center;
  vertical-align: middle;
}

.day-arrow,
.day-page-button {
  font-size: 1.8rem;
}

.day-cell[aria-selected="true"] {
  background: #1a1a1a;
  color: #fffdf6;
}

.day-arrow:disabled,
.day-page-button:disabled {
  border-style: dashed;
  background: #ded8c8;
  color: #6c665b;
  cursor: default;
}

.lesson-toolbar .text-button {
  float: right;
}

.day-menu {
  position: absolute;
  z-index: 8;
  top: 58px;
  right: 8px;
  left: 8px;
  padding: 10px;
  white-space: normal;
}

.day-menu-head {
  overflow: hidden;
  margin-bottom: 10px;
}

.day-menu-title {
  display: inline-block;
  width: calc(100% - 98px);
  text-align: center;
  vertical-align: middle;
}

.day-menu-title .tiny-label {
  margin-bottom: 2px;
}

.day-menu-range {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 900;
}

.day-grid {
  overflow: hidden;
  margin: -3px;
}

.day-cell {
  width: 18%;
  margin: 3px 1%;
  border-radius: 12px;
  font-size: 0.95rem;
}

.card-topline {
  overflow: hidden;
  border-bottom: 3px solid #1f1f1f;
  padding: 6px 12px;
  color: #34312c;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

#lesson-counter {
  float: left;
}

#lesson-theme {
  float: right;
}

.picture-frame {
  height: 190px;
  overflow: hidden;
  border-bottom: 3px solid #1f1f1f;
  background: #ded8c8;
  text-align: center;
}

.picture-frame svg {
  display: block;
  width: 224px;
  max-width: 96%;
  max-height: 182px;
  margin: 0 auto;
  padding: 8px;
}

.generated-word-image {
  display: block;
  width: 182px;
  max-width: 92%;
  max-height: 182px;
  margin: 4px auto;
  object-fit: contain;
}

.picture-frame path,
.picture-frame circle,
.picture-frame ellipse,
.picture-frame line,
.picture-frame rect,
.picture-frame polygon {
  vector-effect: non-scaling-stroke;
}

.word-block {
  padding: 10px 14px 8px;
  text-align: center;
}

.word-block h2 {
  margin-bottom: 2px;
  font-size: 86px;
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.pronunciation {
  margin-bottom: 2px;
  color: #6c665b;
  font-size: 1.45rem;
  font-weight: 700;
}

.meaning {
  margin-bottom: 0;
  font-size: 1.7rem;
  font-weight: 900;
}

.parent-cue {
  display: inline-block;
  max-width: 100%;
  margin: 8px 0 0;
  border: 3px solid #1f1f1f;
  border-radius: 16px;
  padding: 7px 12px;
  background: #faf7ee;
  font-size: 1.1rem;
  font-weight: 900;
}

.actions {
  clear: both;
  padding: 6px 14px 10px;
  text-align: center;
}

.button {
  display: inline-block;
  width: 46%;
  min-height: 56px;
  margin: 0 1%;
  border: 3px solid #1f1f1f;
  border-radius: 18px;
  background: #faf7ee;
  color: #111;
  box-shadow: 4px 4px 0 #1a1a1a;
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 900;
}

.text-button {
  display: inline-block;
  min-width: 46px;
  min-height: 46px;
  border: 3px solid #1f1f1f;
  border-radius: 50%;
  padding: 0;
  background: #faf7ee;
  color: #111;
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 40px;
  text-align: center;
}

.symbol-button {
  font-size: 3rem;
  line-height: 1;
}

.button:active {
  -webkit-transform: translate(3px, 3px);
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 #1a1a1a;
}

.button.primary {
  background: #1a1a1a;
  color: #fffdf6;
}

.guide-steps {
  border-top: 3px solid #1f1f1f;
  padding-top: 18px;
}

.guide-steps h2 {
  margin-bottom: 12px;
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.parent-steps {
  margin: 0;
  padding-left: 1.3em;
  font-size: 1.05rem;
  font-weight: 700;
}

.parent-steps li {
  margin-bottom: 8px;
}

.guide-start {
  width: 100%;
  margin-top: 20px;
}

@supports (display: grid) {
  html {
    min-height: 100%;
    overflow-x: hidden;
    background:
      radial-gradient(circle at 14px 14px, rgba(17, 17, 17, 0.11) 1px, transparent 1px),
      linear-gradient(135deg, #f8f5ec 0%, #ebe5d5 100%);
    background-size: 28px 28px, 100% 100%;
  }

  body {
    min-height: 100%;
    overflow-x: hidden;
  }

  .app-shell {
    display: block;
    width: 100%;
    max-width: none;
    min-height: 0;
    overflow: visible;
    margin: 0;
    padding: 4px 7px 7px 4px;
    padding: clamp(4px, 0.8vh, 7px) clamp(6px, 1vh, 10px) clamp(6px, 1vh, 10px) clamp(4px, 0.8vh, 7px);
  }

  .panel {
    border-radius: 28px;
    box-shadow: 3px 3px 0 #1a1a1a;
  }

  .guide {
    top: 50%;
    right: auto;
    bottom: auto;
    left: 50%;
    width: min(calc(100% - 28px), 720px);
    max-height: calc(100vh - 28px);
    max-height: calc(100dvh - 28px);
    margin: auto;
    padding: 26px;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
  }

  .guide::backdrop {
    background:
      radial-gradient(circle at 14px 14px, rgba(17, 17, 17, 0.22) 1px, transparent 1px),
      rgba(244, 241, 232, 0.92);
    background-size: 24px 24px, 100% 100%;
  }

  .guide-layout {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    align-items: center;
  }

  .guide-layout {
    margin-bottom: 24px;
  }

  h1 {
    margin-bottom: 12px;
    font-size: clamp(2.35rem, 8vw, 4.7rem);
  }

  .intro {
    font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  }

  .daily-mark {
    display: grid;
    place-items: center;
    width: 116px;
    height: 116px;
    margin: 0;
    background:
      linear-gradient(90deg, transparent 47%, rgba(17, 17, 17, 0.16) 48% 52%, transparent 53%),
      #ded8c8;
  }

  .daily-mark span {
    padding-top: 0;
    font-size: 3.8rem;
  }

  .daily-mark small {
    margin-top: -12px;
  }

  .learning-card {
    display: block;
    min-height: 0;
    overflow: visible;
  }

  .lesson-toolbar {
    display: grid;
    grid-template-columns: minmax(96px, 1fr) auto auto auto;
    align-items: center;
    gap: 6px;
    overflow: visible;
    padding: 6px 10px;
    padding: clamp(5px, 1vh, 8px) 10px;
    white-space: normal;
  }

  .day-select-button {
    display: grid;
    align-content: center;
    min-width: 0;
    min-height: clamp(36px, 5.2vh, 44px);
    margin: 0;
    padding: 4px 12px;
    border-radius: 14px;
  }

  .day-title {
    overflow: hidden;
    font-size: clamp(1rem, 2.6vh, 1.25rem);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .day-progress {
    font-size: clamp(0.66rem, 1.6vh, 0.8rem);
  }

  .day-arrow,
  .day-page-button,
  .day-cell {
    display: grid;
    min-width: clamp(36px, 6vw, 44px);
    min-height: clamp(36px, 5.2vh, 44px);
    margin: 0;
    place-items: center;
    font-size: clamp(1.2rem, 3.2vw, 1.45rem);
    line-height: normal;
  }

  .day-arrow,
  .day-page-button {
    font-size: clamp(1.7rem, 4.6vw, 2.2rem);
  }

  .lesson-toolbar .text-button {
    float: none;
    min-width: clamp(36px, 6vw, 44px);
    min-height: clamp(36px, 5.2vh, 44px);
  }

  .day-menu {
    top: calc(100% + 8px);
    right: 12px;
    left: 12px;
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 18px;
    box-shadow: 7px 7px 0 #1a1a1a;
  }

  .day-menu[hidden] {
    display: none;
  }

  .day-menu-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 0;
  }

  .day-menu-title {
    display: block;
    width: auto;
  }

  .day-menu-range {
    font-size: clamp(1rem, 2.4vh, 1.2rem);
  }

  .day-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
  }

  .day-cell {
    width: auto;
    min-width: 0;
    min-height: clamp(42px, 6.2vh, 54px);
    margin: 0;
    border-radius: 12px;
    font-size: clamp(0.84rem, 2.1vh, 1rem);
  }

  .card-topline {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 16px;
    padding: clamp(6px, 1.2vh, 10px) 16px;
    font-size: clamp(0.95rem, 2.2vh, 1.05rem);
  }

  #lesson-counter,
  #lesson-theme {
    float: none;
  }

  .picture-frame {
    display: grid;
    height: 190px;
    height: clamp(150px, 31vh, 230px);
    min-height: 0;
    place-items: center;
    background:
      linear-gradient(135deg, rgba(17, 17, 17, 0.08) 25%, transparent 25%) 0 0 / 24px 24px,
      #ded8c8;
  }

  .picture-frame svg {
    width: min(72vw, 220px, 31vh);
    max-height: calc(100% - 12px);
    padding: clamp(6px, 1.2vh, 10px);
  }

  .generated-word-image {
    width: min(72vw, 210px, 31vh);
    max-height: calc(100% - 12px);
    margin: 6px auto;
  }

  .word-block {
    padding: clamp(8px, 1.4vh, 12px) 18px clamp(6px, 1vh, 10px);
  }

  .word-block h2 {
    font-size: clamp(4.7rem, 13.5vh, 6.2rem);
    line-height: 0.86;
    letter-spacing: -0.08em;
  }

  .pronunciation {
    margin-bottom: clamp(2px, 0.7vh, 4px);
    font-size: clamp(1.25rem, 3.4vh, 1.75rem);
  }

  .meaning {
    font-size: clamp(1.45rem, 4.2vh, 2rem);
  }

  .parent-cue {
    margin-top: clamp(6px, 1.1vh, 10px);
    padding: clamp(6px, 1vh, 9px) 12px;
    font-size: clamp(1.05rem, 2.8vh, 1.32rem);
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: clamp(6px, 1.1vh, 10px) 18px clamp(9px, 1.7vh, 15px);
    text-align: left;
  }

  .button {
    width: auto;
    min-height: clamp(48px, 7vh, 62px);
    margin: 0;
    border-radius: 18px;
    font-size: clamp(1.15rem, 3.6vw, 1.5rem);
    box-shadow: 4px 4px 0 #1a1a1a;
  }

  .text-button {
    display: grid;
    min-width: 48px;
    min-height: 48px;
    place-items: center;
    line-height: normal;
  }

  .symbol-button {
    font-size: clamp(1.8rem, 6vw, 2.6rem);
  }

  .parent-steps {
    display: grid;
    gap: 12px;
    font-size: clamp(1.05rem, 3vw, 1.25rem);
  }

  .parent-steps li {
    margin-bottom: 0;
  }
}

@media (orientation: landscape) and (min-width: 960px) and (hover: hover) {
  .app-shell {
    width: 100%;
    max-width: 430px;
    max-width: 56vh;
    max-width: 56dvh;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 8px;
  }

  h1 {
    font-size: 42px;
  }

  .guide {
    padding: 20px;
  }

  .picture-frame {
    height: 178px;
  }

  .picture-frame svg {
    width: 208px;
    max-height: 170px;
  }

  .generated-word-image {
    width: min(70vw, 170px);
    max-height: 170px;
  }

  .word-block {
    padding: 10px 16px 8px;
  }

  .word-block h2 {
    font-size: 88px;
  }

  .pronunciation {
    font-size: 1.38rem;
  }

  .meaning {
    font-size: 1.62rem;
  }

  .parent-cue {
    margin-top: 8px;
    padding: 7px 12px;
    font-size: 1rem;
  }

  .daily-mark {
    width: 92px;
    height: 92px;
  }

  .daily-mark span {
    font-size: 3rem;
  }

  .actions {
    padding-top: 8px;
    padding-bottom: 14px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .button {
    min-height: 52px;
    font-size: 1.35rem;
  }

  .symbol-button {
    font-size: 2.2rem;
  }

  .lesson-toolbar {
    padding-right: 8px;
    padding-left: 8px;
  }
}

@media (max-height: 680px) {
  .tiny-label {
    display: none;
  }

  .picture-frame {
    height: 150px;
  }

  .generated-word-image {
    width: min(64vw, 142px);
    max-height: calc(100% - 10px);
    margin: 5px auto;
  }

  .text-button {
    min-height: 40px;
  }

  .day-arrow,
  .day-page-button,
  .day-cell {
    min-width: 34px;
    min-height: 34px;
    line-height: 28px;
  }

  .day-select-button {
    min-height: 34px;
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .day-menu {
    top: calc(100% + 6px);
  }

  .word-block h2 {
    font-size: 84px;
  }

  .parent-cue {
    overflow: hidden;
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-height: 560px) {
  .app-shell {
    padding: 6px;
  }

  .panel {
    border-radius: 20px;
  }

  .picture-frame {
    height: 118px;
  }

  .generated-word-image {
    width: min(58vw, 110px);
    max-height: calc(100% - 8px);
    margin: 4px auto;
  }

  .card-topline,
  .lesson-toolbar {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .word-block {
    padding-top: 6px;
  }

  .actions {
    padding-top: 6px;
    padding-bottom: 8px;
  }

  .button {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .panel {
    -webkit-animation: settle 420ms steps(2, end) both;
    animation: settle 420ms steps(2, end) both;
  }

  @-webkit-keyframes settle {
    from {
      opacity: 0.78;
    }

    to {
      opacity: 1;
    }
  }

  @keyframes settle {
    from {
      opacity: 0.78;
    }

    to {
      opacity: 1;
    }
  }
}

@media (monochrome) {
  html,
  body {
    background: #fff;
  }

  .panel,
  .guide,
  .button,
  .text-button,
  .day-select-button,
  .day-arrow,
  .day-page-button,
  .day-cell,
  .parent-cue {
    background: #fff;
  }

  .panel,
  .button,
  .day-menu {
    box-shadow: none;
  }

  .picture-frame,
  .daily-mark,
  .day-arrow:disabled,
  .day-page-button:disabled {
    background: #eee;
  }
}

@media print {
  .button,
  .panel {
    box-shadow: none;
  }

  .panel {
    break-inside: avoid;
  }
}
