:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-strong: #f0f6f2;
  --ink: #1f2723;
  --muted: #66716b;
  --line: #d9e1db;
  --green: #176f5a;
  --green-dark: #0f5746;
  --coral: #d65f45;
  --amber: #ad7417;
  --shadow: 0 16px 45px rgba(36, 46, 42, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(23, 111, 90, 0.08), rgba(246, 247, 243, 0) 32rem),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 20px clamp(16px, 4vw, 32px) 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 9vw, 4.3rem);
  line-height: 0.98;
  font-weight: 850;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
}

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

.account-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 520px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: clamp(16px, 4vw, 20px);
}

.account-copy p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 0;
}

.composer {
  padding: clamp(16px, 4vw, 24px);
}

form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.field-hint {
  min-height: 1.25rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  outline: none;
}

input {
  height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 92px;
  resize: vertical;
  padding: 12px 14px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 111, 90, 0.13);
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  font-weight: 750;
}

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

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

.secondary-button {
  background: var(--surface-strong);
  color: var(--green-dark);
}

.secondary-button:hover {
  background: #e4efe8;
}

.icon-button {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--green);
  font-size: 1rem;
}

.icon-button:hover {
  border-color: var(--green);
}

.library {
  margin-top: 18px;
  overflow: hidden;
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 230px);
  gap: 12px;
  align-items: end;
  padding: clamp(16px, 4vw, 22px);
  border-bottom: 1px solid var(--line);
}

.section-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
}

.word-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.word-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 86px;
  padding: 16px clamp(16px, 4vw, 22px);
  border-bottom: 1px solid var(--line);
}

.word-card:last-child {
  border-bottom: 0;
}

.word-main {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.word-text {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.2rem;
}

.meaning-text {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.speed-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.speed-button,
.standard-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 750;
}

.standard-button {
  background: var(--surface-strong);
}

.speed-button:hover,
.standard-button:hover {
  border-color: var(--green);
  background: var(--surface-strong);
}

.word-actions {
  display: flex;
  gap: 4px;
}

.text-button {
  min-height: 38px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
}

.text-button:hover {
  color: var(--ink);
  background: #f1f3ef;
}

.delete-button:hover {
  color: var(--coral);
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
}

.empty-state[hidden],
.word-list[hidden],
.auth-form[hidden],
button[hidden] {
  display: none;
}

@media (max-width: 640px) {
  .account-panel,
  .auth-form,
  .section-heading,
  .word-card {
    grid-template-columns: 1fr;
  }

  .word-actions {
    justify-content: flex-end;
  }

  .form-actions {
    grid-template-columns: 1fr;
  }
}
