:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef4ef;
  --ink: #20221f;
  --muted: #646b62;
  --line: #d9ded5;
  --green: #2f7d58;
  --green-dark: #1f5e43;
  --teal: #1e756f;
  --coral: #c9583b;
  --amber: #b67821;
  --shadow: 0 18px 45px rgba(41, 51, 38, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 22px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.nav a.active,
.nav a:hover {
  background: var(--surface-2);
  border-color: var(--line);
}

.side-note {
  margin-top: auto;
  padding: 14px;
  border-radius: 8px;
  background: #fff8ec;
  border: 1px solid #efd6af;
  color: #6c4a19;
  font-size: 13px;
  line-height: 1.55;
}

.main {
  padding: 28px;
  max-width: 1180px;
  width: 100%;
}

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

.eyebrow {
  margin: 0 0 7px;
  color: var(--green-dark);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  font-size: 32px;
  line-height: 1.15;
}

h3 {
  margin: 0 0 12px;
  font-size: 19px;
}

p {
  line-height: 1.65;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.card {
  padding: 18px;
}

.metric {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.metric span {
  color: var(--muted);
  font-size: 14px;
}

.hero-task {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

.phrase {
  font-size: 34px;
  line-height: 1.1;
  font-weight: 800;
  margin: 10px 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #edf1e7;
  color: #40513c;
  font-size: 12px;
  font-weight: 700;
}

.tag.warn {
  background: #fff0dc;
  color: #7b4b0e;
}

.tag.good {
  background: #e6f4ec;
  color: #1f6645;
}

.tag.coral {
  background: #fdebe6;
  color: #8f321d;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  text-decoration: none;
  cursor: pointer;
  font-weight: 750;
  line-height: 1.2;
}

.button:hover {
  filter: brightness(1.05);
}

.button.primary {
  background: var(--green);
}

.button.secondary {
  background: #eef2ea;
  color: var(--ink);
  border: 1px solid var(--line);
}

.button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.button.coral {
  background: var(--coral);
}

.button.amber {
  background: var(--amber);
}

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

.unit-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.material-list {
  display: grid;
  gap: 10px;
}

.material-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.35fr) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.material-row strong {
  font-size: 17px;
}

.field {
  display: grid;
  gap: 7px;
  margin: 14px 0;
}

.field label {
  font-weight: 750;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

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

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 88, 0.16);
}

.coach-result {
  border-left: 4px solid var(--green);
  padding-left: 16px;
}

.sentence {
  font-size: 20px;
  line-height: 1.55;
  font-weight: 750;
}

.review-box {
  display: grid;
  gap: 16px;
  max-width: 820px;
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
}

.library-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.attempt-log {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.attempt-log div {
  padding: 10px;
  border-radius: 8px;
  background: #f6f8f3;
  border: 1px solid var(--line);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  background: var(--ink);
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  max-width: 360px;
}

.kbd {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  background: #f0f2ed;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav a {
    white-space: nowrap;
  }

  .side-note {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .hero-task,
  .grid.two,
  .grid.three,
  .library-filters,
  .input-action,
  .material-row {
    grid-template-columns: 1fr;
  }

  h2 {
    font-size: 26px;
  }

  .phrase {
    font-size: 28px;
  }
}
