:root {
  color-scheme: light;
  --ink: #262522;
  --muted: #746f68;
  --soft: #f7f1e8;
  --paper: #fffaf1;
  --paper-strong: #fff6e7;
  --line: rgba(53, 49, 43, 0.12);
  --shadow: rgba(41, 37, 31, 0.16);
  --shadow-strong: rgba(34, 31, 27, 0.28);
  --accent: #2f2f2d;
  --accent-soft: #e8dcc9;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 250, 241, 0.98), rgba(246, 238, 225, 0.78) 45%, rgba(238, 229, 214, 0.92) 100%),
    #f3eadc;
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}

button,
input,
textarea {
  font: inherit;
}

a { color: inherit; }

.page-shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 650;
  letter-spacing: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 9px;
  background: #f3eadc;
  box-shadow: 0 12px 24px rgba(39, 40, 39, 0.12);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.top-tabs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.66);
  backdrop-filter: blur(18px);
  border-radius: 999px;
}

.tab-button,
.admin-link,
.secondary-action {
  border: 0;
  text-decoration: none;
  color: var(--muted);
  background: transparent;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.tab-button.active,
.admin-link:hover,
.secondary-action:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px rgba(69, 57, 43, 0.08);
}

main {
  flex: 1;
  display: flex;
}

.view-panel {
  display: none;
  width: 100%;
}

.view-panel.active {
  display: block;
}

.hero-grid {
  min-height: calc(100vh - 128px);
  display: grid;
  grid-template-columns: minmax(280px, 0.74fr) minmax(360px, 1fr);
  align-items: center;
  gap: clamp(30px, 7vw, 88px);
  padding: 10px 0 58px;
}

.eyebrow {
  margin: 0 0 14px;
  color: #9a8972;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 18px;
  font-size: clamp(3rem, 8vw, 6.7rem);
  line-height: 0.92;
  letter-spacing: 0;
  font-weight: 680;
}

.hero-intro {
  max-width: 460px;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.18rem);
  line-height: 1.9;
}

.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 28px;
}

.primary-action,
.admin-submit,
.quiet-button {
  appearance: none;
  border: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  text-decoration: none;
  box-shadow: 0 16px 28px rgba(39, 39, 37, 0.18);
  cursor: pointer;
}

.primary-action.disabled {
  pointer-events: none;
  color: rgba(255, 255, 255, 0.64);
  background: rgba(47, 47, 45, 0.36);
  box-shadow: none;
}

.download-note {
  color: #8b8175;
  font-size: 0.92rem;
}

.book-stage {
  position: relative;
  min-height: 610px;
  display: grid;
  place-items: center;
}

.featured-book-card {
  position: relative;
  z-index: 2;
  width: min(410px, 82vw);
  text-align: center;
}

.book-object {
  position: relative;
  border-radius: 9px 15px 15px 9px;
  background: #fff7eb;
  box-shadow:
    0 34px 54px var(--shadow-strong),
    15px 20px 0 rgba(72, 63, 52, 0.07);
  transform: perspective(900px) rotateY(-9deg) rotateX(2deg);
  transform-origin: center;
}

.book-object::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 26px;
  border-radius: 9px 0 0 9px;
  background: linear-gradient(90deg, rgba(31, 29, 26, 0.2), rgba(255, 255, 255, 0.08));
  mix-blend-mode: multiply;
  pointer-events: none;
}

.book-object::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 10%;
  bottom: -25px;
  height: 28px;
  border-radius: 999px;
  background: rgba(48, 43, 36, 0.23);
  filter: blur(16px);
  transform: rotate(2deg);
  z-index: -1;
}

.large-book img,
.history-book img,
.side-book {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: inherit;
}

.large-book {
  width: min(325px, 70vw);
  margin: 0 auto;
}

.book-meta {
  margin-top: 42px;
}

.book-meta .hero-actions {
  justify-content: center;
  margin-top: 22px;
}

.meta-label {
  margin-bottom: 8px;
  color: #a0907b;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.book-meta h2 {
  margin-bottom: 8px;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  letter-spacing: 0;
}

.book-meta p:not(.meta-label):not(.download-note) {
  color: var(--muted);
  line-height: 1.7;
}

#featured-rec {
  margin-bottom: 0;
}

.side-book {
  position: absolute;
  width: 138px;
  height: 205px;
  opacity: 0.62;
  background:
    linear-gradient(140deg, rgba(255, 251, 242, 0.65), rgba(216, 204, 186, 0.82)),
    url("/assets/notta-story-cover-en.png") center / cover;
  box-shadow: 0 20px 34px rgba(66, 57, 46, 0.18);
}

.side-book-left {
  left: 12%;
  bottom: 126px;
  transform: perspective(800px) rotateY(22deg) rotateZ(-8deg);
}

.side-book-right {
  right: 7%;
  top: 92px;
  transform: perspective(800px) rotateY(-20deg) rotateZ(8deg);
}

.section-heading {
  padding-top: 86px;
  margin-bottom: 28px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  letter-spacing: 0;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 28px;
  padding-bottom: 72px;
}

.history-card {
  min-height: 100%;
}

.history-book {
  width: 170px;
  margin-bottom: 28px;
  transform: perspective(800px) rotateY(-8deg);
}

.history-card h3 {
  margin-bottom: 8px;
  font-size: 1.12rem;
}

.history-card p {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.65;
}

.history-download {
  display: inline-flex;
  margin-top: 8px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid rgba(38, 37, 34, 0.32);
}

.empty-state {
  color: var(--muted);
  padding: 42px 0;
}

.admin-page {
  background: #f5ecdf;
}

.admin-layout {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding-bottom: 64px;
}

.admin-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 58px 0 32px;
}

.admin-hero h1 {
  font-size: clamp(2.6rem, 6vw, 5rem);
  margin-bottom: 10px;
}

.admin-hero p {
  color: var(--muted);
  margin-bottom: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) 1fr;
  gap: 26px;
  align-items: start;
}

.admin-card,
.book-row {
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.76);
  box-shadow: 0 18px 42px rgba(70, 58, 43, 0.08);
  border-radius: 18px;
}

.admin-card {
  padding: 24px;
}

.admin-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.toggle-field span {
  color: #5c554d;
  font-size: 0.9rem;
  font-weight: 650;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid rgba(49, 45, 39, 0.16);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  padding: 12px 13px;
  outline: none;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(47, 47, 45, 0.5);
  box-shadow: 0 0 0 4px rgba(47, 47, 45, 0.08);
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field-help {
  color: #968a7d;
  font-size: 0.82rem;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.quiet-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--line);
  box-shadow: none;
}

.status-line {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.9rem;
}

.book-list {
  display: grid;
  gap: 14px;
}

.book-row {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 16px;
  padding: 14px;
  align-items: center;
}

.book-row img {
  width: 84px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 12px 20px rgba(52, 45, 36, 0.16);
}

.book-row h3 {
  margin-bottom: 4px;
}

.book-row p {
  margin-bottom: 5px;
  color: var(--muted);
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-button {
  min-width: 42px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.68);
  cursor: pointer;
}

.danger { color: #9a3430; }

.file-field input[type="file"] {
  width: 100%;
  padding: 14px 12px;
  border: 1px dashed rgba(49, 45, 39, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
}

.toggle-field input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

@media (max-width: 820px) {
  .page-shell,
  .admin-layout {
    width: min(100% - 28px, 720px);
  }

  /* Compact top bar: brand left, tabs top-right */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    min-height: 0;
    padding: 8px 0 6px;
    align-items: center;
    flex-direction: row;
    gap: 10px;
    background: linear-gradient(
      180deg,
      rgba(243, 234, 220, 0.97) 0%,
      rgba(243, 234, 220, 0.9) 72%,
      rgba(243, 234, 220, 0)
    );
    backdrop-filter: blur(10px);
  }

  .admin-page .site-header {
    background: linear-gradient(
      180deg,
      rgba(245, 236, 223, 0.97) 0%,
      rgba(245, 236, 223, 0.9) 72%,
      rgba(245, 236, 223, 0)
    );
  }

  .brand {
    min-height: 0;
    gap: 8px;
    font-size: 0.92rem;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    box-shadow: 0 6px 14px rgba(39, 40, 39, 0.1);
  }

  .brand > span:last-child {
    font-size: 0.9rem;
    font-weight: 600;
  }

  .top-tabs {
    width: auto;
    margin-left: auto;
    flex-shrink: 0;
    gap: 2px;
    padding: 3px;
  }

  .top-tabs > * {
    flex: none;
    text-align: center;
    min-height: 32px;
    padding: 5px 10px;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .tab-extra {
    display: none;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    min-height: auto;
    gap: 0;
    padding: 4px 0 28px;
  }

  /* Mobile today: hide large site wordmark; book + download fill first screen */
  .view-panel[data-panel="today"] .hero-copy {
    display: none;
  }

  .book-stage {
    order: 1;
    min-height: 0;
    padding: 4px 0 0;
  }

  .side-book {
    display: none;
  }

  .featured-book-card {
    width: min(300px, 88vw);
  }

  .large-book {
    width: min(148px, 38vw);
  }

  .book-object {
    transform: perspective(900px) rotateY(-5deg) rotateX(1deg);
    box-shadow:
      0 18px 28px var(--shadow-strong),
      10px 12px 0 rgba(72, 63, 52, 0.06);
  }

  .book-object::before {
    width: 16px;
  }

  .book-object::after {
    bottom: -14px;
    height: 18px;
    filter: blur(12px);
  }

  .book-meta {
    margin-top: 14px;
  }

  .meta-label {
    margin-bottom: 4px;
    font-size: 0.7rem;
  }

  .book-meta h2 {
    margin-bottom: 4px;
    font-size: 1.28rem;
    line-height: 1.25;
  }

  #featured-author {
    margin-bottom: 8px;
    font-size: 0.88rem;
  }

  #featured-rec {
    font-size: 0.9rem;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
  }

  .book-meta .hero-actions {
    margin-top: 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .primary-action {
    width: 100%;
    min-height: 44px;
    padding: 0 16px;
    box-shadow: 0 10px 18px rgba(39, 39, 37, 0.14);
  }

  .download-note {
    text-align: center;
    font-size: 0.8rem;
  }

  .section-heading {
    padding-top: 28px;
  }

  .section-heading h2 {
    font-size: clamp(1.6rem, 7vw, 2.2rem);
  }

  .history-grid {
    grid-template-columns: 1fr;
    gap: 22px;
    padding-bottom: calc(48px + env(safe-area-inset-bottom, 0));
  }

  .history-book {
    width: min(150px, 42vw);
    margin-bottom: 18px;
  }

  .admin-hero {
    display: grid;
    grid-template-columns: 1fr;
    padding: 28px 0 18px;
    align-items: start;
  }

  .admin-hero h1 {
    font-size: clamp(2.2rem, 11vw, 3.2rem);
  }

  .admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .admin-card {
    padding: 18px;
  }

  .admin-form {
    gap: 14px;
  }

  .field input,
  .field textarea {
    min-height: 48px;
    font-size: 16px; /* avoid iOS zoom on focus */
    padding: 13px 14px;
  }

  .field textarea {
    min-height: 110px;
  }

  .admin-actions {
    gap: 10px;
  }

  .admin-actions-sticky {
    position: sticky;
    bottom: calc(10px + env(safe-area-inset-bottom, 0));
    z-index: 15;
    padding: 10px;
    margin: 4px -6px 0;
    border-radius: 16px;
    background: rgba(255, 250, 242, 0.92);
    border: 1px solid var(--line);
    box-shadow: 0 12px 30px rgba(70, 58, 43, 0.12);
    backdrop-filter: blur(12px);
  }

  .admin-submit,
  .quiet-button {
    flex: 1;
    min-height: 48px;
  }

  .book-row {
    grid-template-columns: 72px 1fr;
    gap: 12px;
    padding: 12px;
  }

  .book-row img {
    width: 72px;
  }

  .row-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .row-actions .icon-button {
    flex: 1;
    min-height: 44px;
  }

  .admin-layout {
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0));
  }
}

@media (max-width: 520px) {
  .page-shell,
  .admin-layout {
    width: calc(100% - 20px);
  }

  .brand > span:last-child {
    font-size: 0.84rem;
  }

  .top-tabs > * {
    padding: 5px 8px;
    font-size: 0.74rem;
  }

  .large-book {
    width: min(132px, 36vw);
  }

  .book-meta h2 {
    font-size: 1.18rem;
  }

  #featured-rec {
    -webkit-line-clamp: 3;
    font-size: 0.86rem;
  }

  .history-card h3 {
    font-size: 1.05rem;
  }
}

@media (max-width: 360px) {
  .brand > span:last-child {
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .large-book {
    width: min(120px, 34vw);
  }
}
