:root {
  color-scheme: light;
  --ink: #18212a;
  --muted: #697583;
  --soft: #8a96a3;
  --line: #d9e1e7;
  --line-strong: #c6d1da;
  --panel: #f6f8fa;
  --paper: #ffffff;
  --accent: #0f766e;
  --accent-strong: #0b534e;
  --accent-soft: #e3f4f1;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --gold: #b7791f;
  --gold-soft: #fff7e6;
  --rose: #9f4058;
  --shadow: 0 20px 60px rgba(24, 33, 42, 0.12);
  --shadow-soft: 0 8px 24px rgba(24, 33, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(37, 99, 235, 0.05) 46%, rgba(255, 255, 255, 0)),
    #eef2f5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(24, 33, 42, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 33, 42, 0.035) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
}

button,
input {
  font: inherit;
}

button {
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

button:active {
  transform: translateY(1px);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 22px;
  width: min(1240px, calc(100vw - 36px));
  min-height: calc(100vh - 36px);
  margin: 18px auto;
}

.search-panel,
.entry-card {
  border: 1px solid rgba(198, 209, 218, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.search-panel {
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: calc(100vh - 36px);
  min-height: 0;
  padding: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2.35rem, 6vw, 4.2rem);
  font-weight: 900;
  line-height: 0.92;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.search-box {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.search-box input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
}

.search-box input::placeholder {
  color: var(--soft);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.online-button,
.sound-button {
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 850;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.online-button {
  min-height: 48px;
  width: 100%;
  background: var(--blue);
}

.online-button:hover,
.online-button:focus-visible {
  background: #1d4ed8;
}

.lookup-status {
  min-height: 20px;
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.word-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding: 2px 4px 2px 0;
}

.word-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(76px, auto);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--ink);
  background: rgba(246, 248, 250, 0.82);
  text-align: left;
  cursor: pointer;
}

.word-button strong,
.word-button span {
  overflow-wrap: anywhere;
}

.word-button strong {
  font-size: 1rem;
}

.word-button span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.25;
  text-align: right;
}

.word-button:hover,
.word-button.is-active {
  border-color: rgba(15, 118, 110, 0.38);
  background: var(--accent-soft);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.08);
}

.entry-panel {
  min-width: 0;
}

.entry-card {
  min-height: 100%;
  padding: clamp(22px, 4vw, 44px);
}

.entry-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.word-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(2.6rem, 8vw, 5.8rem);
  font-weight: 900;
  line-height: 0.92;
  overflow-wrap: anywhere;
}

.pos,
.chip,
.syllable {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.86rem;
  font-weight: 850;
}

.pos {
  color: #ffffff;
  background: var(--rose);
  box-shadow: 0 8px 16px rgba(159, 64, 88, 0.18);
}

.phonetic {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 750;
}

.sound-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 100px;
  min-height: 46px;
  background: var(--accent);
}

.sound-button:hover {
  background: var(--accent-strong);
}

.entry-card section {
  margin-top: 28px;
}

h3 {
  margin-bottom: 12px;
  color: #23313d;
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.definition-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.definition-strip > div,
.example,
.origin-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 1px 0 rgba(24, 33, 42, 0.03);
}

.definition-strip > div {
  padding: 17px 18px;
}

.definition-strip > div:first-child {
  border-left: 4px solid var(--accent);
}

.definition-strip > div:last-child {
  border-left: 4px solid var(--gold);
}

.definition-strip p {
  margin-bottom: 0;
  font-size: 1.12rem;
  line-height: 1.6;
}

.label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.syllables,
.chips,
.sources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.syllable {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.examples {
  display: grid;
  gap: 12px;
}

.example {
  padding: 15px 17px;
}

.origin-box {
  padding: 16px 18px;
  background: var(--gold-soft);
  border-color: rgba(183, 121, 31, 0.28);
}

.origin-box p {
  margin-bottom: 8px;
  line-height: 1.58;
}

.origin-box p:last-child {
  margin-bottom: 0;
  color: #6c5d44;
}

.example p {
  margin-bottom: 7px;
  line-height: 1.55;
}

.example p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.word-relations {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.chip {
  color: #23313d;
  background: #eef2f5;
}

.relation-chip {
  border: 1px solid transparent;
  cursor: pointer;
}

.relation-chip:hover,
.relation-chip:focus-visible {
  border-color: rgba(15, 118, 110, 0.28);
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 8px 16px rgba(15, 118, 110, 0.16);
}

.source-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-radius: 8px;
  padding: 6px 12px;
  color: #1d4ed8;
  background: var(--blue-soft);
  font-weight: 850;
  text-decoration: none;
}

.source-link:hover {
  border-color: rgba(37, 99, 235, 0.5);
  background: #dce8ff;
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100vw - 20px, 720px);
    margin: 10px auto;
  }

  .search-panel {
    position: static;
    height: auto;
    max-height: none;
  }

  .word-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 230px;
  }

  .entry-header,
  .definition-strip,
  .word-relations {
    grid-template-columns: 1fr;
  }

  .entry-header {
    display: grid;
  }

  .sound-button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .app-shell {
    width: min(100vw - 16px, 420px);
    margin: 8px auto;
  }

  .search-panel,
  .entry-card {
    padding: 18px;
  }

  .word-list {
    grid-template-columns: 1fr;
  }
}
