* {
  box-sizing: border-box;
}

html,
body,
#root {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

html {
  background: #dfe9e4;
  color: #20241e;
  color-scheme: light;
  font-family: Georgia, "Times New Roman", "Noto Serif SC", "Songti SC", serif;
  line-height: 1.45;
}

body {
  position: fixed;
  inset: 0;
  background: #dfe9e4;
}

button {
  font: inherit;
}

.device-stage {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.kindle-canvas {
  width: min(100vw, calc(100vh * 3 / 4));
  height: min(100vh, calc(100vw * 4 / 3));
  max-width: 1264px;
  max-height: 1680px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  padding: 16px;
  border: 2px solid #33433b;
  border-radius: 8px;
  background: #fffdf6;
}

.screen {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: 76px minmax(0, 1fr) 70px;
  gap: 12px;
}

.screen[hidden] {
  display: none;
}

.canvas-header,
.canvas-footer {
  min-height: 0;
  border: 2px solid #33433b;
  border-radius: 8px;
  background: #f5f1df;
}

.canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
}

.brand-block {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-block img {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
}

.brand-block p,
.cell-eyebrow,
.cell-meta,
.page-meter,
.canvas-footer p {
  margin: 0;
  color: #536b62;
  font-family: "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  overflow-wrap: break-word;
}

h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.05;
}

h2 {
  margin: 0;
  font-size: 23px;
  line-height: 1.12;
}

.page-meter {
  flex: 0 0 auto;
  min-width: 58px;
  padding: 8px 10px;
  border: 2px solid #33433b;
  border-radius: 8px;
  background: #d8e8ee;
  color: #20241e;
  text-align: center;
}

.story-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 12px;
  overflow: hidden;
}

.story-card,
.grid-cell {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  border: 2px solid #33433b;
  border-radius: 8px;
  background: #fffdf6;
}

.story-card {
  grid-template-columns: 38% minmax(0, 1fr);
  gap: 0;
  padding: 0;
  color: #20241e;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.story-card--wide {
  grid-column: span 2;
}

.story-card--paper,
.grid-cell--paper {
  background: #fffdf6;
}

.story-card--sage,
.grid-cell--sage {
  background: #d7eadf;
}

.story-card--sky,
.grid-cell--sky {
  background: #d8e8ee;
}

.story-card--sun,
.grid-cell--sun {
  background: #f3c46d;
}

.story-card--rose,
.grid-cell--rose {
  background: #f2d5c8;
}

.story-cover {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-right: 2px solid #33433b;
  background: rgba(255, 253, 246, 0.52);
}

.story-cover img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.story-card-copy {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 12px;
}

.story-card-copy strong {
  display: block;
  font-size: 20px;
  line-height: 1.12;
}

.story-card-copy span:last-child {
  display: block;
  font-size: 15px;
  line-height: 1.36;
}

.reader-grid {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 12px;
  overflow: hidden;
}

.reader-art,
.reader-copy {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 2px solid #33433b;
  border-radius: 8px;
}

.reader-art {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.reader-art img {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.reader-copy {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  overflow: hidden;
  background: #fffdf6;
}

.story-text {
  margin: 0;
  font-size: 22px;
  line-height: 1.52;
}

.cell-meta {
  margin-top: 2px;
  color: #20241e;
}

.canvas-footer {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 118px;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.canvas-footer p {
  min-width: 0;
  color: #20241e;
  text-align: center;
}

.canvas-footer button {
  min-width: 0;
  min-height: 46px;
  border: 2px solid #33433b;
  border-radius: 8px;
  background: #fffdf6;
  color: #20241e;
  cursor: pointer;
  font-family: "Helvetica Neue", Arial, "PingFang SC", sans-serif;
  font-size: 15px;
  font-weight: 700;
}

.canvas-footer button:disabled {
  color: #7a8277;
  background: #e7e5d8;
  cursor: default;
}

.canvas-footer span {
  display: inline-block;
  min-width: 16px;
  font-size: 18px;
  line-height: 1;
}

button:focus {
  outline: 3px solid #7b9f8c;
  outline-offset: 2px;
}

.story-card:active,
.canvas-footer button:active {
  background: #e7e5d8;
}

@media (max-width: 560px), (max-height: 740px) {
  .device-stage {
    padding: 0;
  }

  .kindle-canvas {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    padding: 10px;
  }

  .screen {
    grid-template-rows: 66px minmax(0, 1fr) 64px;
    gap: 8px;
  }

  h1 {
    font-size: 23px;
  }

  h2 {
    font-size: 19px;
  }

  .story-card-copy strong {
    font-size: 17px;
  }

  .story-card-copy span:last-child {
    font-size: 13px;
    line-height: 1.28;
  }

  .story-text {
    font-size: 15px;
    line-height: 1.42;
  }

  .brand-block img {
    width: 38px;
    height: 38px;
  }

  .canvas-footer {
    grid-template-columns: 92px minmax(0, 1fr) 92px;
  }

  .canvas-footer button {
    font-size: 13px;
    min-height: 42px;
  }
}

@media (prefers-color-scheme: dark) {
  html,
  body,
  .device-stage {
    background: #dfe9e4;
    color: #20241e;
  }
}
