:root {
  color-scheme: light;
  --bg: #171412;
  --paper: #fffaf0;
  --paper-2: #f2eadb;
  --ink: #211c18;
  --muted: rgba(33, 28, 24, 0.62);
  --line: rgba(33, 28, 24, 0.14);
  --red: #bc0b0e;
  --blue: #0f6c8f;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  overflow-x: clip;
}

button,
input {
  font: inherit;
}

.app {
  width: 100%;
  max-width: 760px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  overflow-x: clip;
}

.sticky-panel {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.96);
  backdrop-filter: blur(10px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 9px 8px 8px;
  border-bottom: 1px solid var(--line);
}

.topbar > div {
  min-width: 0;
}

.kicker {
  margin: 0 0 2px;
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.download-link,
.search-row button,
.mode-controls button,
.tabs button,
.toggle-text {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.download-link {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--red);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.tabs {
  display: flex;
  justify-content: flex-end;
  justify-self: end;
  gap: 4px;
  width: auto;
  min-width: 0;
  padding: 0;
  overflow-x: visible;
}

.tabs button {
  flex: 0 0 34px;
  width: 34px;
  min-height: 36px;
  padding: 6px 0;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
}

.tabs button.active {
  border-color: rgba(188, 11, 14, 0.36);
  background: #fce7df;
  color: var(--red);
}

.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  padding: 8px 8px 4px;
}

h2 {
  margin: 0;
  min-width: 0;
  font-size: 21px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  min-width: 0;
}

.mode-controls button {
  min-height: 38px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 850;
}

.mode-controls button.active {
  border-color: rgba(15, 108, 143, 0.36);
  background: #dff2f7;
  color: var(--blue);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px minmax(240px, 300px);
  gap: 8px;
  align-items: center;
  padding: 4px 8px 8px;
}

.search-row input {
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
}

.search-row button {
  min-height: 38px;
  border-radius: 6px;
  font-weight: 800;
}

.word-list {
  padding: 10px 14px 22px;
}

.group-title {
  position: sticky;
  top: var(--sticky-panel-height, 154px);
  z-index: 5;
  margin: 10px -2px 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(242, 234, 219, 0.96);
  color: var(--red);
  font-size: 14px;
  font-weight: 950;
}

.word-card {
  display: grid;
  grid-template-columns: 34px minmax(0, calc(50% - 34px)) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.word-no {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.english,
.korean {
  overflow-wrap: anywhere;
}

.toggle-text {
  display: inline;
  width: auto;
  max-width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: inherit;
  overflow-wrap: anywhere;
}

.toggle-text.is-hidden {
  display: inline-block;
  min-width: min(150px, 100%);
  height: 1.25em;
  border-radius: 4px;
  background: #2a2520;
  color: transparent;
  vertical-align: -0.18em;
}

.english,
.toggle-text.english {
  font-size: 19px;
  line-height: 1.25;
  font-weight: 900;
}

.korean,
.toggle-text.korean {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.35;
  font-weight: 700;
  text-align: left;
}

.toggle-text.is-hidden,
.toggle-text.english.is-hidden,
.toggle-text.korean.is-hidden {
  color: transparent;
}

.empty {
  padding: 30px 0;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

@media (min-width: 640px) {
  .topbar {
    padding-left: 18px;
    padding-right: 18px;
  }

  .word-list,
  .section-head,
  .search-row {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (max-width: 520px) {
  .topbar {
    min-height: 54px;
    padding: 8px 8px 7px;
  }

  h1 {
    font-size: 18px;
  }

  .section-head {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    padding-top: 7px;
    padding-bottom: 4px;
  }

  h2 {
    font-size: 18px;
  }

  .tabs,
  .mode-controls {
    gap: 5px;
  }

  .tabs {
    gap: 4px;
    position: static;
    width: auto;
  }

  .tabs button,
  .mode-controls button {
    min-height: 34px;
    font-size: 12px;
  }

  .tabs button {
    flex-basis: 32px;
    width: 32px;
    padding: 6px 0;
  }

  .mode-controls button {
    padding: 6px 9px;
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) 58px minmax(174px, 0.95fr);
    gap: 6px;
  }

  .search-row input {
    height: 36px;
    padding: 0 9px;
  }

  .search-row button {
    min-height: 34px;
  }

  .group-title {
    top: var(--sticky-panel-height, 142px);
  }
}
