:root {
  --u6g-navy: #071f4f;
  --u6g-green: #17785f;
  --u6g-green-dark: #0c5d49;
  --u6g-coral: #cf4a44;
  --u6g-gold: #d9a441;
  --u6g-ink: #182235;
  --u6g-muted: #526176;
  --u6g-paper: #ffffff;
  --u6g-soft: #f1f8f5;
  --u6g-blue-soft: #edf3fc;
  --u6g-gold-soft: #fff7e2;
  --u6g-coral-soft: #fff1ef;
  --u6g-border: #d8e4e0;
  --u6g-shadow: 0 16px 38px rgba(7, 31, 79, 0.12);
}

* {
  box-sizing: border-box;
}

body.unit6-grammar-page {
  overflow-x: hidden;
  background: #f4f7fb;
  color: var(--u6g-ink);
}

.u6g-hero {
  min-height: clamp(480px, 72vh, 690px);
  display: grid;
  align-items: end;
  width: 100%;
  padding: 5.5rem 1.25rem 2.2rem;
  color: #fff;
  background:
    linear-gradient(120deg, rgba(7, 31, 79, 0.94) 0%, rgba(7, 31, 79, 0.78) 48%, rgba(23, 120, 95, 0.28) 100%),
    url("../img/english-intermediate/unit-6/unit-6-grammar-storybook-page-1.webp") center / cover no-repeat;
}

.u6g-hero-content {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.u6g-hero .eyebrow {
  display: inline-flex;
  width: fit-content;
  margin: 0 0 0.85rem;
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  background: rgba(255, 255, 255, 0.94);
  color: var(--u6g-navy);
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.u6g-hero h1 {
  max-width: 820px;
  margin: 0 0 1rem;
  font-size: clamp(2.3rem, 6vw, 4.8rem);
  line-height: 1;
  letter-spacing: 0;
}

.u6g-hero p:not(.eyebrow) {
  max-width: 730px;
  margin: 0;
  color: #f8fbff;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.58;
}

.u6g-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1.25rem 0;
}

.u6g-meta span {
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 850;
  line-height: 1.15;
}

.u6g-actions,
.storybook-actions,
.delivery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.u6g-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
  scroll-margin-top: 96px;
}

.u6g-panel {
  margin-bottom: 1.25rem;
  overflow: hidden;
  border: 1px solid var(--u6g-border);
  border-radius: 8px;
  background: var(--u6g-paper);
  box-shadow: var(--u6g-shadow);
}

.u6g-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.2rem;
  border-bottom: 1px solid var(--u6g-border);
  background: linear-gradient(135deg, #ffffff, #eef8f5);
}

.u6g-panel-head h2 {
  margin: 0;
  color: var(--u6g-navy);
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.u6g-panel-head p:not(.kicker) {
  max-width: 800px;
  margin: 0.45rem 0 0;
  color: var(--u6g-muted);
  line-height: 1.55;
}

.kicker {
  margin: 0 0 0.35rem;
  color: var(--u6g-coral);
  font-size: 0.77rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.u6g-panel-body {
  padding: 1.2rem;
}

.grammar-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.grammar-map article {
  min-width: 0;
  border: 1px solid var(--u6g-border);
  border-radius: 8px;
  padding: 0.85rem;
  background: #f8fbfd;
}

.grammar-map strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--u6g-navy);
  font-size: 1.02rem;
}

.grammar-map span {
  color: var(--u6g-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.storybook-status {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.progress-wrap {
  display: grid;
  gap: 0.4rem;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfeaf2;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--u6g-green), var(--u6g-gold));
  transition: width 180ms ease;
}

.counter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  color: var(--u6g-muted);
  font-size: 0.9rem;
  font-weight: 850;
}

.counter-row strong {
  color: var(--u6g-navy);
}

.score-pill {
  justify-self: end;
  border-radius: 999px;
  padding: 0.55rem 0.75rem;
  background: var(--u6g-blue-soft);
  color: var(--u6g-navy);
  font-weight: 950;
  white-space: nowrap;
}

.storybook-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  min-height: 500px;
  border: 1px solid #c9b88d;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(7, 31, 79, 0.11), transparent 2.2%, transparent 97.8%, rgba(7, 31, 79, 0.12)),
    #fffdf5;
  box-shadow:
    0 24px 48px rgba(7, 31, 79, 0.16),
    inset 0 0 0 8px rgba(255, 255, 255, 0.72);
  overflow: hidden;
}

.storybook-card.is-open::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 1rem;
  bottom: 1rem;
  left: 50%;
  width: 18px;
  transform: translateX(-50%);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(7, 31, 79, 0.18), rgba(255, 255, 255, 0.88) 48%, rgba(7, 31, 79, 0.16));
  box-shadow:
    -16px 0 22px rgba(7, 31, 79, 0.08),
    16px 0 22px rgba(7, 31, 79, 0.08);
  pointer-events: none;
}

.storybook-card.is-cover {
  display: block;
  min-height: 540px;
  padding: 1rem;
  background:
    linear-gradient(100deg, rgba(7, 31, 79, 0.18), transparent 12%, transparent 88%, rgba(7, 31, 79, 0.22)),
    #0a2559;
}

.book-cover {
  position: relative;
  min-height: 508px;
  display: grid;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  padding: clamp(1rem, 4vw, 3.2rem);
  overflow: hidden;
  background:
    linear-gradient(110deg, rgba(7, 31, 79, 0.95) 0%, rgba(7, 31, 79, 0.84) 42%, rgba(23, 120, 95, 0.30) 100%),
    url("../img/english-intermediate/unit-6/unit-6-grammar-storybook-page-4.webp") center / cover no-repeat;
  color: #fff;
  box-shadow: inset 16px 0 28px rgba(0, 0, 0, 0.26), inset -8px 0 18px rgba(255, 255, 255, 0.12);
}

.book-cover-edge {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 1.35rem;
  width: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(217, 164, 65, 0.94), rgba(255, 247, 226, 0.42), rgba(217, 164, 65, 0.9));
  box-shadow: 16px 0 28px rgba(0, 0, 0, 0.22);
}

.book-cover::after {
  content: "";
  position: absolute;
  right: 0.8rem;
  top: 0.8rem;
  bottom: 0.8rem;
  width: 34px;
  border-radius: 0 8px 8px 0;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92) 2px, rgba(226, 233, 241, 0.92) 3px, rgba(226, 233, 241, 0.92) 5px);
  opacity: 0.92;
}

.book-cover-content {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  margin-left: clamp(1.4rem, 3vw, 2.2rem);
}

.book-series {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 0.42rem 0.7rem;
  background: rgba(255, 255, 255, 0.94);
  color: var(--u6g-navy);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.book-cover h3 {
  max-width: 620px;
  margin: 0.85rem 0 0.8rem;
  color: #fff;
  font-size: clamp(2.3rem, 6vw, 4.7rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.book-cover p {
  max-width: 560px;
  margin: 0;
  color: #f8fbff;
  font-size: clamp(1rem, 2vw, 1.16rem);
  line-height: 1.58;
}

.book-cover-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1.15rem 0 1.25rem;
}

.book-cover-tags span {
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  padding: 0.4rem 0.62rem;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 900;
}

.storybook-figure {
  position: relative;
  margin: 0;
  min-width: 0;
  padding: 1.25rem 1.1rem 1.25rem 1.25rem;
  background:
    linear-gradient(90deg, #fffef8, #f8f1df);
}

.storybook-figure img {
  display: block;
  width: 100%;
  height: min(370px, 44vw);
  min-height: 300px;
  object-fit: cover;
  border: 1px solid #e6d8b7;
  border-radius: 6px;
  box-shadow: 0 16px 28px rgba(7, 31, 79, 0.12);
}

.storybook-figure figcaption {
  margin-top: 0.85rem;
  border-top: 1px solid #eadfca;
  padding: 0.75rem 0 0;
  color: #5f5140;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.35;
}

.storybook-copy {
  display: grid;
  align-content: center;
  gap: 0.85rem;
  min-width: 0;
  padding: 1.65rem 1.45rem 1.65rem 1.7rem;
  background:
    linear-gradient(90deg, #f6edd7, #fffef8 5%, #fffef8 95%, #f6edd7),
    #fffef8;
}

.storybook-copy .page-label {
  width: fit-content;
  border-radius: 999px;
  padding: 0.4rem 0.65rem;
  background: var(--u6g-gold-soft);
  color: #744d00;
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.storybook-copy h3 {
  margin: 0;
  color: var(--u6g-navy);
  font-size: clamp(1.45rem, 3vw, 2.05rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.story-text {
  display: grid;
  gap: 0.75rem;
  font-size: clamp(1rem, 1.6vw, 1.1rem);
  line-height: 1.8;
  color: var(--u6g-ink);
  font-family: Georgia, "Times New Roman", serif;
}

.story-text p {
  margin: 0;
}

.blank-select {
  max-width: min(100%, 245px);
  min-width: 145px;
  margin: 0 0.14rem;
  border: 1px solid #b9c9d9;
  border-radius: 8px;
  padding: 0.36rem 0.55rem;
  background: #f8fbff;
  color: var(--u6g-navy);
  font: 850 0.95rem/1.25 Arial, Helvetica, sans-serif;
  font-size: 0.95rem;
}

.blank-select:focus {
  outline: 3px solid rgba(217, 164, 65, 0.45);
  border-color: var(--u6g-gold);
}

.blank-select.is-correct {
  border-color: #16a34a;
  background: #ecfdf5;
  color: #065f46;
}

.blank-select.is-review {
  border-color: #dc2626;
  background: #fff1f2;
  color: #7f1d1d;
}

.page-note {
  border-left: 4px solid var(--u6g-green);
  padding: 0.75rem 0.85rem;
  background: var(--u6g-soft);
  color: #15483b;
  font-weight: 850;
  line-height: 1.5;
}

.storybook-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.85rem;
  align-items: center;
  margin-top: 1rem;
}

.u6g-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  font: inherit;
  font-weight: 950;
  line-height: 1.15;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.u6g-button:hover,
.u6g-button:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

.u6g-button.primary {
  background: var(--u6g-coral);
  color: #fff;
}

.u6g-button.primary:hover,
.u6g-button.primary:focus-visible {
  background: #b83d38;
}

.u6g-button.navy {
  background: var(--u6g-navy);
  color: #fff;
}

.u6g-button.soft {
  border-color: var(--u6g-border);
  background: #eef5ff;
  color: var(--u6g-navy);
}

.u6g-button.ghost {
  border-color: #c6d6e3;
  background: #fff;
  color: var(--u6g-navy);
}

.u6g-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.feedback-box {
  min-height: 58px;
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin-top: 1rem;
  border: 1px solid var(--u6g-border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: #f8fbfd;
  color: #38506b;
  font-weight: 850;
  line-height: 1.45;
}

.feedback-box::before {
  content: "i";
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #dbeafe;
  color: var(--u6g-navy);
}

.feedback-box.success {
  border-color: #86efac;
  background: #ecfdf5;
  color: #065f46;
}

.feedback-box.success::before {
  content: "OK";
  background: #d1fae5;
  color: #047857;
  font-size: 0.68rem;
}

.feedback-box.error {
  border-color: #fecaca;
  background: #fff1f2;
  color: #7f1d1d;
}

.feedback-box.error::before {
  content: "!";
  background: #fee2e2;
  color: #b42318;
}

.review-list {
  display: none;
  margin-top: 0.85rem;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.85rem;
  background: #fff7f7;
  color: #7f1d1d;
  font-weight: 850;
  line-height: 1.55;
}

.review-list.is-visible {
  display: block;
}

.review-list.is-success {
  border-color: #86efac;
  background: #f0fdf4;
  color: #065f46;
}

.review-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.6rem 0;
}

.review-summary span {
  border-radius: 999px;
  padding: 0.32rem 0.55rem;
  background: #fff;
  color: var(--u6g-navy);
  font-size: 0.84rem;
  font-weight: 950;
}

.review-correct-list {
  margin: 0.35rem 0 0.55rem;
  color: inherit;
}

.reflection-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: 1rem;
  align-items: start;
}

.reflection-brief {
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 1rem;
  background: linear-gradient(145deg, #eff6ff, #fff8e8);
  color: #17365d;
}

.reflection-brief h3 {
  margin: 0 0 0.55rem;
  color: var(--u6g-navy);
}

.reflection-brief p,
.reflection-brief li {
  color: #29445f;
  line-height: 1.55;
}

.reflection-brief ul {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
}

.target-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.target-bank span {
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  background: #eff6ff;
  color: #17365d;
  font-size: 0.82rem;
  font-weight: 900;
}

.delivery-form {
  border: 1px solid var(--u6g-border);
  border-radius: 8px;
  padding: 1rem;
  background: #fff;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.field label {
  color: var(--u6g-navy);
  font-weight: 900;
}

.field textarea {
  width: 100%;
  min-height: 165px;
  resize: vertical;
  border: 1px solid var(--u6g-border);
  border-radius: 8px;
  padding: 0.75rem 0.8rem;
  background: #fbfdff;
  color: var(--u6g-ink);
  font: inherit;
  line-height: 1.55;
}

.field textarea:focus {
  outline: 3px solid rgba(23, 120, 95, 0.16);
  border-color: var(--u6g-green);
}

.word-count {
  color: var(--u6g-muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.delivery-note {
  margin: 0.2rem 0 0.8rem;
  color: var(--u6g-muted);
  line-height: 1.5;
}

.delivery-status {
  display: none;
  margin-top: 0.9rem;
  border-radius: 8px;
  padding: 0.9rem;
  font-weight: 850;
  line-height: 1.5;
}

.delivery-status.show {
  display: block;
}

.delivery-status.success {
  border: 1px solid #86efac;
  background: #ecfdf5;
  color: #065f46;
}

.delivery-status.error {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #7f1d1d;
}

@media (max-width: 980px) {
  .grammar-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .storybook-card,
  .reflection-grid {
    grid-template-columns: 1fr;
  }

  .storybook-card.is-open::before {
    display: none;
  }

  .storybook-card {
    min-height: 0;
  }

  .storybook-figure img {
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  .storybook-figure,
  .storybook-copy {
    padding: 1rem;
  }
}

@media (max-width: 820px) {
  .unit6-grammar-page .site-header {
    position: static;
    top: auto;
  }

  .unit6-grammar-page .navbar {
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    max-width: 100vw;
    padding: 8px 10px 6px;
    overflow: hidden;
  }

  .unit6-grammar-page .brand img {
    height: 38px;
  }

  .unit6-grammar-page .nav-links {
    display: none !important;
  }

  .unit6-grammar-page .nav-links li {
    min-width: 0 !important;
  }

  .unit6-grammar-page .nav-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 34px;
    padding: 0 8px;
    font-size: 0.76rem;
    line-height: 1.15;
    text-align: center;
    white-space: normal !important;
  }

  .unit6-grammar-page .global-course-switcher {
    position: static;
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    margin: 0.35rem 0 0.2rem;
    padding: 0 12px;
  }

  .unit6-grammar-page .global-course-switcher summary {
    min-height: 40px;
  }

  .unit6-grammar-page .global-course-switcher nav {
    right: auto;
    left: 50%;
    top: calc(100% + 0.5rem);
    bottom: auto;
    width: min(260px, calc(100vw - 24px));
    transform: translateX(-50%);
  }

  .unit6-grammar-page .jaralingua-auth {
    z-index: 1300;
    pointer-events: auto;
  }

  .u6g-hero {
    min-height: auto;
    padding: 1rem 1rem 1.05rem;
    align-items: start;
    background-position: center top;
  }

  .u6g-hero h1 {
    max-width: 100%;
    margin-bottom: 0.65rem;
    font-size: clamp(2rem, 10vw, 3rem);
    line-height: 1.04;
  }

  .u6g-hero p:not(.eyebrow) {
    display: none;
  }

  .u6g-meta {
    margin: 0.7rem 0;
    gap: 0.42rem;
  }

  .u6g-meta span {
    padding: 0.38rem 0.58rem;
    font-size: 0.78rem;
  }

  .u6g-meta span:nth-child(n+4) {
    display: none;
  }

  .u6g-actions {
    gap: 0.48rem;
  }

  .u6g-actions .btn:not(:first-child) {
    display: none;
  }

  .u6g-shell {
    width: min(100% - 1rem, 1180px);
    padding-top: 1rem;
    scroll-margin-top: 12px;
  }

  .u6g-panel-head,
  .u6g-panel-body,
  .storybook-copy {
    padding: 0.9rem;
  }

  .storybook-card.is-cover {
    min-height: 0;
    padding: 0.7rem;
  }

  .book-cover {
    min-height: 430px;
    padding: 1.15rem;
  }

  .book-cover-content {
    margin-left: 1.1rem;
    padding-right: 1rem;
  }

  .book-cover::after {
    width: 18px;
  }

  .book-cover-edge {
    left: 0.65rem;
    width: 9px;
  }

  .grammar-map,
  .storybook-status {
    grid-template-columns: 1fr;
  }

  .score-pill {
    justify-self: start;
  }

  .storybook-footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .storybook-actions,
  .delivery-actions,
  .u6g-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .u6g-button,
  .u6g-actions .btn {
    width: 100%;
  }

  .blank-select {
    display: inline-block;
    max-width: 100%;
    min-width: min(210px, 100%);
    margin: 0.2rem 0.1rem;
  }
}

@media (max-width: 460px) {
  .u6g-hero h1 {
    font-size: clamp(1.9rem, 10vw, 2.65rem);
  }

  .u6g-meta {
    display: grid;
    grid-template-columns: 1fr;
  }

  .story-text {
    line-height: 1.72;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
