@font-face {
  font-family: Inter;
  src: url('/flash/assets/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f7f2e8;
  --ink: #181613;
  --muted: #635b4e;
  --rule: #dcd1bf;
  --accent: #2737bd;
  --accent-soft: #e8e9fc;
  --display: Georgia, 'Noto Serif KR', 'AppleMyungjo', serif;
  --ease: cubic-bezier(.22,.8,.22,1);
  --header-offset: 60px;
  background: var(--paper);
  scroll-padding-top: calc(var(--header-offset) + 12px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); font: 15px/1.55 Inter, system-ui, sans-serif; }
body::before { content: ''; position: fixed; inset: auto 0 100%; height: 100lvh; background: var(--paper); pointer-events: none; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
svg { width: 20px; height: 20px; flex: none; }
::selection { background: var(--accent); color: white; }

.dict-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.dict-header {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--rule);
  transition: border-color .24s var(--ease), box-shadow .24s var(--ease);
}

.dict-header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--paper);
  transition: background-color .24s var(--ease);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .dict-scrolled .dict-header::before {
    background-color: rgb(247 242 232 / .84);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
}

.dict-scrolled .dict-header { border-color: rgb(128 108 74 / .2); box-shadow: 0 6px 18px rgb(70 52 26 / .06); }
.dict-header-inner, .dict-shell { width: min(1040px, 100% - 64px); margin-inline: auto; }

.dict-header-inner {
  min-height: 56px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.dict-brand { display: inline-flex; align-items: center; justify-self: start; min-height: 44px; }
.dict-brand img { display: block; object-fit: contain; filter: brightness(0); }
.dict-sections, .dict-locales { display: flex; align-items: center; }
.dict-sections { gap: clamp(12px, 2.6vw, 36px); }
.dict-locales { justify-self: end; gap: 4px; }

.dict-sections a, .dict-locale {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  transition: color .2s;
}

.dict-sections a:hover, .dict-locale:hover { color: var(--accent); }
.dict-sections [aria-current], .dict-locale[aria-current] { color: var(--accent); font-weight: 720; }
.dict-locale { gap: 6px; padding-inline: 8px; font-size: 11px; letter-spacing: .025em; }
.dict-locale img { object-fit: cover; border-radius: 2px; }
.dict-shell { padding-block: clamp(24px, 3.9vw, 52px) 56px; }
.dict-shell:focus { outline: none; }

.dict-term-heading h1 {
  font: 400 clamp(39px, 5.4vw, 72px)/1.02 var(--display);
  letter-spacing: -.065em;
  overflow-wrap: anywhere;
}

:lang(ko) .dict-term-heading h1 {
  font-family: 'Noto Serif KR', 'AppleMyungjo', Batang, serif;
  font-size: clamp(34px, 4.6vw, 60px);
  letter-spacing: -.065em;
  line-height: 1.12;
  font-weight: 650;
  word-break: keep-all;
}

.dict-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-block-end: 12px;
  background: #fffcf6;
  border: 1px solid #caba9e;
  padding-inline: 12px 9px;
  border-radius: 8px;
  min-height: 48px;
  transition: border-color .2s, background-color .2s, box-shadow .2s;
}

.dict-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px #2737bd21; background: white; }
.dict-search label { display: flex; color: var(--accent); }
.dict-search input { border: 0; outline: 0; background: transparent; width: 100%; min-width: 0; font-size: 16px; padding: 10px 0; }
.dict-search input::placeholder { color: var(--muted); }
.dict-search input::-webkit-search-cancel-button { appearance: none; }
.dict-search kbd { padding: 0 8px; border: 1px solid var(--rule); border-radius: 4px; color: var(--muted); }
.dict-clear { display: grid; place-items: center; width: 34px; height: 34px; flex: none; padding: 0; border: 0; border-radius: 5px; color: var(--accent); background: var(--accent-soft); }
.dict-clear:not([hidden]) + kbd { display: none; }

.dict-rail { position: relative; }

.dict-categories, .dict-letters {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.dict-rail::before, .dict-rail::after {
  content: '';
  position: absolute;
  inset-block: 0;
  width: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s var(--ease);
}

.dict-rail::before { left: 0; background: linear-gradient(to right, var(--paper), transparent); }
.dict-rail::after { right: 0; background: linear-gradient(to left, var(--paper), transparent); }
.dict-rail:has([data-overflow-start]):not(:has(:focus-visible))::before,
.dict-rail:has([data-overflow-end]):not(:has(:focus-visible))::after { opacity: 1; }

.dict-categories { padding-block: 4px 6px; }
.dict-categories button, .dict-letters button {
  border: 0;
  outline: 0;
  flex: none;
  font-weight: 650;
  background: #eee5d5;
  color: #514939;
  transition: color .2s, background-color .2s;
}

.dict-categories button { display: inline-flex; gap: 7px; align-items: baseline; min-height: 36px; padding: 7px 11px; border-radius: 6px; white-space: nowrap; font-size: 13px; }
.dict-categories small { font-size: 11px; font-variant-numeric: tabular-nums; opacity: .8; }
.dict-categories button:focus-visible, .dict-letters button:focus-visible { background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.dict-categories button[aria-pressed=true], .dict-letters button[aria-pressed=true] { background: var(--accent); color: white; }
.dict-categories button[aria-pressed=true]:focus-visible, .dict-letters button[aria-pressed=true]:focus-visible { background: #162285; text-decoration: underline; }

.dict-index-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 16px; }
.dict-index-bar h1, .dict-related-list h2 { font: 400 clamp(21px, 2.3vw, 28px)/1.16 var(--display); letter-spacing: -.035em; }
.dict-result-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.dict-letters { gap: 3px; min-height: 38px; margin: 4px 0 3px; }
.dict-letters button { background: transparent; color: var(--muted); min-width: 31px; min-height: 34px; border-radius: 5px; font-size: 13px; }

.dict-letter-section {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  border-top: 1px solid var(--ink);
}

.dict-letter-section + .dict-letter-section { margin-top: 10px; }
.dict-letter-section h3 { padding-top: 11px; color: var(--accent); font: 400 35px/1 var(--display); letter-spacing: -.045em; }

.dict-entry {
  display: grid;
  grid-template-columns: minmax(132px, 1fr) minmax(0, 2.3fr) minmax(74px, .6fr) 19px;
  align-items: center;
  gap: 15px;
  min-height: 50px;
  padding: 9px 7px 9px 0;
  transition: background-color .21s, color .21s;
}

.dict-letter-section li + li { border-top: 1px solid var(--rule); }
.dict-entry-word { min-width: 0; display: grid; gap: 3px; overflow-wrap: anywhere; }
.dict-entry-word strong { font-size: 16px; line-height: 1.28; font-weight: 680; letter-spacing: -.028em; }
.dict-entry-word small, .dict-related small { color: var(--muted); font-size: 11px; }
.dict-entry-meaning { color: var(--muted); font-size: 13px; }
.dict-entry-kind { color: var(--accent); font-size: 11px; font-weight: 650; }
.dict-entry svg, .dict-related svg { width: 17px; height: 17px; color: var(--accent); transition: transform .24s var(--ease); }
.dict-empty { padding: 30px 0; border-top: 1px solid var(--ink); }
.dict-empty button { margin-top: 10px; border: 0; padding: 8px 0; background: transparent; color: var(--accent); font-weight: 650; text-decoration: underline; }

.dict-detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: clamp(18px, 2.8vw, 32px);
}

.dict-back { display: inline-flex; gap: 8px; min-height: 44px; align-items: center; font-weight: 650; font-size: 13px; }
.dict-back svg { width: 18px; height: 18px; color: var(--accent); }
.dict-term-kind { color: var(--accent); font-size: 12px; font-weight: 700; }
.dict-term-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(165px, .35fr); align-items: start; gap: clamp(24px, 4.2vw, 60px); }
.dict-shell[data-entry]:not([data-entry=""]) { padding-top: clamp(14px, 2vw, 28px); }
.dict-term-heading h1 { font-size: clamp(36px, 4.9vw, 64px); }
.dict-term-heading p { margin-top: 7px; color: var(--muted); font-size: clamp(15px, 1.7vw, 18px); }
.dict-definitions { margin-top: clamp(16px, 2.7vw, 30px); }
.dict-definition section { padding: 16px 0; border-top: 1px solid var(--rule); }
.dict-definition section + section { border-color: var(--accent); }
.dict-definition section h2 { color: var(--accent); font-size: 12px; font-weight: 750; }
.dict-definition section p { max-width: 62ch; margin-top: 6px; font-size: clamp(15px, 1.65vw, 18px); line-height: 1.65; }
.dict-related-list { border-top: 2px solid var(--accent); padding-top: 11px; }
.dict-related-list h2 { font-size: 22px; }
.dict-related-list ul { margin-top: 8px; }
.dict-related-list li { border-bottom: 1px solid var(--rule); }
.dict-related { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; }
.dict-related span { display: grid; gap: 1px; }
.dict-related strong { font-size: 14px; font-weight: 700; }

@media (hover: hover) and (pointer: fine) {
  .dict-categories button[aria-pressed=false]:hover, .dict-letters button[aria-pressed=false]:hover { background: var(--accent-soft); color: var(--accent); }
  .dict-entry:hover, .dict-related:hover { background: #efe7d8; color: var(--accent); }
  .dict-entry:hover svg, .dict-related:hover svg { transform: translateX(3px); }
  .dict-back:hover { color: var(--accent); }
}

@media (max-width: 850px) {
  .dict-header-inner, .dict-shell { width: calc(100% - 48px); }
  .dict-entry { grid-template-columns: minmax(116px, 1fr) minmax(0, 2.4fr) 18px; gap: 14px; }
  .dict-entry-kind { display: none; }
  .dict-letter-section { grid-template-columns: 49px minmax(0, 1fr); }
}

@media (max-width: 660px) {
  :root { --header-offset: 88px; }
  .dict-header-inner, .dict-shell { width: calc(100% - 32px); }
  .dict-header-inner { grid-template-columns: 1fr 1fr; min-height: auto; row-gap: 0; padding-top: 5px; }
  .dict-sections { grid-column: 1/-1; grid-row: 2; justify-content: space-between; gap: 12px; }
  .dict-sections a { min-height: 38px; }
  .dict-term-layout { grid-template-columns: minmax(0, 1fr); }
  .dict-search kbd { display: none; }
  .dict-categories { gap: 6px; }
  .dict-categories button, .dict-letters button { min-height: 40px; }
  .dict-letters { gap: 2px; }
  .dict-letter-section { grid-template-columns: 28px minmax(0, 1fr); }
  .dict-letter-section h3 { padding-top: 10px; font-size: 26px; }
  .dict-entry { grid-template-columns: minmax(0, 1fr) 17px; gap: 3px 9px; padding: 8px 5px 8px 0; }
  .dict-entry > svg { grid-area: 1 / 2 / span 2; }
  .dict-entry-word { display: flex; align-items: baseline; gap: 3px 8px; flex-wrap: wrap; }
  .dict-entry-meaning { font-size: 12px; line-height: 1.5; }
  .dict-definition section { padding-block: 13px; }
}

@media (prefers-reduced-motion: no-preference) {
  .dict-term-heading, .dict-definitions {
    animation: dictionary-enter .28s var(--ease) both;
  }
  @keyframes dictionary-enter {
    from { opacity: .88; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .dictionary *, .dictionary *::before, .dictionary *::after { transition: none !important; }
}

.dict-locales { position: relative; }
.dict-locales summary { cursor: pointer; list-style: none; }
.dict-locales summary::-webkit-details-marker { display: none; }
.dict-locales summary::after {
  content: '';
  width: 6px;
  height: 6px;
  margin-inline-start: 3px;
  border: solid currentColor;
  border-width: 0 1px 1px 0;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .22s var(--ease);
}
.dict-locales[open] summary::after { transform: translateY(1px) rotate(225deg); }
.dict-locale-menu {
  position: absolute;
  inset-block-start: calc(100% + 4px);
  inset-inline-end: 0;
  width: max-content;
  min-width: 160px;
  max-height: min(365px, 68dvh);
  overflow: auto;
  padding: 5px;
  border-radius: 13px;
  background: #faf6ee;
  box-shadow: 0 10px 28px rgb(56 41 23 / .15);
}
.dict-locales[open] .dict-locale-menu { animation: dict-language-in .2s var(--ease) both; }
.dict-locale-menu .dict-locale { display: flex; justify-content: start; min-height: 36px; border-radius: 8px; }
.dict-locale-menu :is(a:hover, [aria-current]) { background: var(--accent-soft); }
@keyframes dict-language-in {
  from { opacity: 0; transform: translateY(-4px); }
}
.dict-categories, .dict-letters { direction: ltr; }
.dict-entry-meaning, .dict-entry-word, .dict-related, .dict-definitions { overflow-wrap: anywhere; }
.dict-diagram {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.dict-diagram li {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  background: var(--accent-soft);
  color: var(--accent);
}
.dict-diagram li + li { background: #ede5d7; color: var(--ink); }
.dict-diagram li + li::before { content: '→'; color: var(--muted); }
[dir='rtl'] .dict-diagram li + li::before { content: '←'; }
[dir='rtl'] :is(.dict-back, .dict-entry, .dict-related) svg { scale: -1 1; }

@media (prefers-reduced-motion: reduce) {
  .dict-locales[open] .dict-locale-menu { animation: none; }
  .dict-locales summary::after { transition: none; }
}

.dict-reference {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-block-start: 12px;
  color: var(--muted);
  font-size: 12px;
}
.dict-reference svg { width: 14px; height: 14px; }

.dict-search-sky {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: end;
  min-height: clamp(152px, 19vw, 226px);
  margin-block-end: 14px;
  padding: clamp(12px, 2.1vw, 24px);
  overflow: hidden;
  border-radius: 14px;
  background: radial-gradient(ellipse at 62% 30%, #221d39, transparent 61%), #101017;
}
.dict-galaxy { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.dict-search-sky .dict-search {
  margin: 0;
  width: min(100%, 470px);
  color: #f6f3ff;
  background: #171720ed;
  border-color: #ffffff30;
}
.dict-search-sky .dict-search:focus-within {
  background: #1b1a26;
  border-color: #b6afff;
  box-shadow: 0 0 0 2px #b6afff27;
}
.dict-search-sky .dict-search label { color: #c6baff; }
.dict-search-sky .dict-search input { color: inherit; }
.dict-search-sky .dict-search input::placeholder { color: #c9c4d1; }
.dict-search-sky .dict-search kbd { color: #c9c4d1; border-color: #ffffff36; }
