:root {
  color-scheme: light;
  --color-bg: #f4f6f2;
  --color-surface: #ffffff;
  --color-text: #17201b;
  --color-muted: #5d6a62;
  --color-border: #d8dfda;
  --color-primary: #176b4d;
  --color-primary-dark: #0e5038;
  --color-primary-soft: #e5f2eb;
  --color-danger: #a63737;
  --color-danger-soft: #fff0f0;
  --color-info: #194e78;
  --color-info-soft: #eef6fc;
  --shadow: 0 8px 24px rgb(21 47 34 / 8%);
  font-family:
    -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR",
    "Malgun Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--color-bg);
}

body {
  margin: 0;
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 16px;
  line-height: 1.55;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

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

.page-shell {
  width: min(100% - 32px, 720px);
  margin-inline: auto;
}

.app-header {
  padding: 28px 0 24px;
  color: #fff;
  background: var(--color-primary);
}

.app-header.compact {
  padding-top: 18px;
}

.app-header h1 {
  margin-bottom: 6px;
  font-size: clamp(1.65rem, 6vw, 2.25rem);
  line-height: 1.2;
}

.brand,
.eyebrow {
  margin-bottom: 5px;
  color: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-context {
  margin-bottom: 0;
  color: #d7eee3;
}

.back-link {
  display: inline-block;
  margin-bottom: 18px;
  color: #e2f3ea;
  font-weight: 700;
  text-decoration: none;
}

.content-stack,
.form-page {
  display: grid;
  gap: 24px;
  padding-block: 24px 48px;
}

.hero-card,
.form-section,
.context-card,
.detail-hero,
.sentence-detail-card,
.lesson-list-item {
  border: 1px solid var(--color-border);
  border-radius: 18px;
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  gap: 20px;
  padding: 24px;
}

.hero-card .eyebrow,
.section-heading .eyebrow,
.detail-hero .eyebrow {
  color: var(--color-primary);
}

.hero-card h2,
.section-heading h2,
.detail-hero h2 {
  margin-bottom: 8px;
  line-height: 1.3;
}

.hero-card p:last-child,
.section-heading p:last-child,
.detail-summary {
  margin-bottom: 0;
  color: var(--color-muted);
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid #f0b429;
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.button-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.button-secondary {
  border-color: var(--color-border);
  color: var(--color-text);
  background: var(--color-surface);
}

.button-danger {
  border-color: #e6bcbc;
  color: var(--color-danger);
  background: var(--color-danger-soft);
}

.button-large {
  min-height: 52px;
  padding-inline: 22px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.status-box,
.message {
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  color: var(--color-muted);
  background: var(--color-surface);
}

.status-box.error,
.message-error {
  border-color: #e6bcbc;
  color: #742626;
  background: var(--color-danger-soft);
}

.status-box.success {
  border-color: #a9d7be;
  color: #124b35;
  background: var(--color-primary-soft);
}

.message-info {
  border-color: #bad4e6;
  color: var(--color-info);
  background: var(--color-info-soft);
}

.message ul {
  margin: 8px 0 0;
  padding-left: 22px;
}

.lesson-list,
.sentence-form-list,
.sentence-detail-list {
  display: grid;
  gap: 14px;
}

.lesson-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.lesson-list-item h3 {
  margin-bottom: 4px;
  font-size: 1.08rem;
}

.lesson-date,
.lesson-count {
  margin-bottom: 3px;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.context-card {
  padding: 16px 20px;
}

.context-card dl,
.detail-meta,
.sentence-detail-card dl {
  margin: 0;
}

.context-card dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.context-card dl div,
.detail-meta div,
.sentence-detail-card dl div {
  display: grid;
  gap: 2px;
}

dt {
  color: var(--color-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

dd {
  margin: 0;
  font-weight: 800;
}

.form-section {
  padding: 22px;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 18px;
}

.field label {
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid #adb8b1;
  border-radius: 10px;
  color: var(--color-text);
  background: #fff;
}

textarea {
  resize: vertical;
}

.field-error {
  border-color: var(--color-danger);
  background: #fff8f8;
}

.sentence-card {
  padding: 18px;
  border: 2px solid #d5e3da;
  border-radius: 15px;
  background: #fbfdfb;
}

.sentence-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sentence-card-title {
  margin-bottom: 0;
  color: var(--color-primary);
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 10px;
  padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
}

.detail-hero {
  padding: 24px;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border);
}

.sentence-detail-card {
  padding: 20px;
}

.sentence-detail-card h3 {
  margin-bottom: 16px;
  font-size: 1.25rem;
  line-height: 1.45;
}

.sentence-order {
  margin-bottom: 5px;
  color: var(--color-primary);
  font-size: 0.84rem;
  font-weight: 800;
}

.sentence-detail-card dl {
  display: grid;
  gap: 12px;
}

.developer-info {
  padding: 14px 18px;
  border: 1px dashed var(--color-border);
  border-radius: 12px;
  color: var(--color-muted);
  background: #fafbfa;
}

.developer-info summary {
  min-height: 44px;
  align-content: center;
  cursor: pointer;
  font-weight: 800;
}

.developer-info p {
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

.center-message {
  display: grid;
  min-height: 100vh;
  place-content: center;
  gap: 14px;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (min-width: 640px) {
  .hero-card {
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 30px;
  }

  .app-header {
    padding-block: 36px 30px;
  }
}

@media (max-width: 480px) {
  .page-shell {
    width: min(100% - 24px, 720px);
  }

  .context-card dl {
    grid-template-columns: 1fr;
  }

  .lesson-list-item {
    align-items: stretch;
    flex-direction: column;
  }

  .lesson-list-item .button {
    width: 100%;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .section-heading > .button {
    width: 100%;
  }

  .form-section {
    padding: 18px 16px;
  }

  .sentence-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .remove-sentence {
    width: 100%;
  }
}
