:root {
  --bg: #f6f7f4;
  --ink: #18201c;
  --muted: #68736c;
  --line: #d7ded7;
  --panel: #ffffff;
  --accent: #1f7a5a;
  --accent-dark: #14563f;
  --warn: #b2472f;
  --soft: #e7f2eb;
  --focus: #f5df98;
  --shadow: 0 14px 40px rgba(30, 40, 35, 0.08);
}

* { box-sizing: border-box; }

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

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

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
}

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

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

.primary:hover { background: var(--accent-dark); }

.ghost { background: #fff; }

.small-btn {
  padding: 7px 10px;
  font-size: 14px;
}

.danger {
  background: #fff5f2;
  color: var(--warn);
  border-color: #e6b8aa;
}

.topbar {
  height: 88px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.82);
}

.topbar h1, h2, h3, p { margin: 0; }

.eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  color: var(--accent-dark);
  font-weight: 700;
}

.top-actions, .toolbar, .button-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.sync-status {
  min-width: 116px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.sync-status.pending { color: #705600; }
.sync-status.ok { color: var(--accent-dark); }
.sync-status.error { color: var(--warn); }

.file-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fff;
  cursor: pointer;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  padding: 20px;
  background: #fbfcfa;
}

.day-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  background: var(--soft);
  border-radius: 8px;
}

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

.nav {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.nav-item {
  text-align: left;
  background: transparent;
}

.nav-item.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.stats {
  display: grid;
  gap: 10px;
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.workspace {
  padding: 24px;
  overflow: auto;
}

.view { display: none; }
.view.active { display: block; }

.section-head, .section-mini {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.section-head h2 { font-size: 28px; }

select, .search, input, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.screen-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 360px;
  gap: 18px;
}

.study-panel, .queue-panel, .practice-panel, .word-list-panel, .output-layout > section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.word-meta, .tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag, .chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.word-text {
  font-size: 58px;
  line-height: 1.05;
  margin: 34px 0 8px;
  word-break: break-word;
}

.pos-badge {
  min-height: 34px;
  margin-bottom: 16px;
  color: var(--accent-dark);
  font-size: 22px;
  font-weight: 700;
}

.reveal {
  background: var(--focus);
  border-color: #d2b54e;
  font-weight: 700;
}

.meaning-text {
  margin: 20px 0;
  font-size: 30px;
  line-height: 1.25;
  font-weight: 700;
}

.hidden { visibility: hidden; }

.check-line {
  display: flex;
  align-items: center;
  width: fit-content;
  margin: 16px 0;
}

.check-line input {
  width: 22px;
  height: 22px;
}

.queue-list, .word-list, .library-list {
  display: grid;
  gap: 8px;
  max-height: 58vh;
  overflow: auto;
}

.queue-row, .word-row, .library-row {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.word-row {
  cursor: pointer;
}

.word-row.active {
  border-color: var(--accent);
  background: var(--soft);
}

.practice-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
}

.practice-panel {
  display: grid;
  gap: 14px;
}

.practice-word {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.feedback-box, .output-box {
  min-height: 160px;
  white-space: pre-wrap;
  line-height: 1.65;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.output-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.library-row {
  grid-template-columns: 180px 1fr 100px 74px;
  align-items: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 32, 28, .32);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(620px, 100%);
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.original-meaning {
  line-height: 1.5;
  color: var(--muted);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

@media (max-width: 900px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    gap: 14px;
    flex-direction: column;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .screen-layout, .practice-grid, .output-layout {
    grid-template-columns: 1fr;
  }

  .word-text {
    font-size: 42px;
  }

  .meaning-text {
    font-size: 24px;
  }

  .library-row {
    grid-template-columns: 1fr;
  }

  .sync-status {
    text-align: left;
  }
}
