:root {
  --bg: #f3eee4;
  --bg-deep: #ebe4d6;
  --paper: #fffaf2;
  --ink: #1c1916;
  --muted: #7a7368;
  --line: rgba(31, 58, 50, 0.12);
  --forest: #1f3a32;
  --forest-soft: #2c5247;
  --gold: #b8945a;
  --danger: #9b3d2e;
  --ok: #2f6b4f;
  --shadow: 0 18px 40px rgba(44, 36, 24, 0.08);
  --radius: 22px;
  --nav-h: calc(62px + env(safe-area-inset-bottom));
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(184, 148, 90, 0.16), transparent 50%),
    radial-gradient(900px 420px at 100% 0%, rgba(31, 58, 50, 0.1), transparent 46%),
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(760px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 28px 20px var(--nav-h);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--forest);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.mark svg {
  width: 22px;
  height: 22px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2,
h3 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", Georgia, serif;
  font-weight: 560;
  letter-spacing: -0.02em;
}

h1 {
  margin: 2px 0 0;
  font-size: 30px;
}

.ghost,
.primary,
.chip,
.icon-btn {
  border: 0;
  border-radius: 999px;
}

.ghost,
.icon-btn {
  background: transparent;
  color: var(--forest);
}

.ghost {
  padding: 8px 4px;
  font-size: 13px;
}

.primary {
  background: var(--forest);
  color: #f7f1e6;
  padding: 13px 20px;
  box-shadow: 0 10px 24px rgba(31, 58, 50, 0.22);
}

.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.stack {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.section-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 16px;
  padding: 13px 14px;
  color: var(--ink);
  outline: none;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: rgba(31, 58, 50, 0.35);
  box-shadow: 0 0 0 4px rgba(31, 58, 50, 0.08);
}

.word-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fffdf8;
}

.word-box input {
  flex: 1;
  min-width: 140px;
  border: 0;
  padding: 8px;
  background: transparent;
  box-shadow: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  background: var(--bg-deep);
  color: var(--ink);
  font-size: 13px;
}

.chip button {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 0;
}

.chip.is-on {
  background: var(--forest);
  color: #f6efe3;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.group-card {
  display: grid;
  gap: 10px;
}

.group-card h3 {
  margin: 0;
  font-size: 24px;
}

.meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.note {
  margin: 0;
  color: #4d473e;
  line-height: 1.7;
}

.search-bar {
  display: flex;
  gap: 10px;
}

.search-bar input {
  flex: 1;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.result-head h2 {
  margin: 0;
  font-size: 36px;
}

.ipa {
  color: var(--gold);
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

.sense {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.sense:first-child {
  border-top: 0;
  padding-top: 0;
}

.pos {
  color: var(--forest-soft);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
}

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: 100%;
  margin: 0;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  background: #f4efe6;
  border-top: 1px solid rgba(28, 25, 22, 0.08);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.nav button {
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 4px 0 2px;
  color: #9a9388;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  letter-spacing: 0.04em;
  line-height: 1;
  box-shadow: none;
}

.nav button svg {
  width: 22px;
  height: 22px;
}

.nav button.is-on {
  background: transparent;
  color: var(--forest);
  box-shadow: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 12px);
  transform: translateX(-50%);
  background: var(--forest);
  color: #f6efe3;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.toast.show {
  opacity: 1;
}

.filters {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding-bottom: 2px;
}

.danger {
  color: var(--danger);
}

.install-tip {
  font-size: 12px;
  color: var(--muted);
  max-width: 180px;
  text-align: right;
  line-height: 1.5;
}

@media (max-width: 640px) {
  h1 {
    font-size: 26px;
  }

  .result-head h2 {
    font-size: 30px;
  }
}
