:root {
  --bg: #f2f2f7;
  --paper: #f2f2f7;
  --card: #ffffff;
  --ink: #1c1c1e;
  --muted: #6e6e73;
  --line: rgba(60, 60, 67, .18);
  --flash: #ff3b30;
  --flash-soft: #fff1f0;
  --green: #34c759;
  --green-soft: #effaf2;
  --blue: #007aff;
  --blue-soft: #eef6ff;
  --gold: #ff9f0a;
  --gold-soft: #fff7e8;
}

* { box-sizing: border-box; }
html { background: #e5e5ea; color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Hiragino Sans", "Noto Sans SC", "Yu Gothic UI", system-ui, sans-serif; }
body { margin: 0; min-width: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-frame {
  position: relative;
  width: min(100%, 460px);
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--paper) 0%, #f7f8f2 100%);
}

.topbar { height: 78px; display: flex; align-items: center; padding: 0 18px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; background: linear-gradient(145deg, var(--ink), #3e4f45); box-shadow: 0 5px 12px rgba(65,107,87,.18); }
.brand-icon svg { width: 25px; fill: var(--flash); stroke: var(--paper); stroke-width: 1.8; stroke-linecap: round; }
.brand > span:last-child { display: grid; gap: 1px; }
.brand strong { font-family: "Yu Mincho", "Noto Serif JP", serif; font-size: 20px; letter-spacing: .04em; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .08em; }
main { flex: 1; min-width: 0; padding: 0 16px 28px; }

.search-bar {
  height: 52px;
  display: grid;
  grid-template-columns: 24px 1fr 34px;
  align-items: center;
  gap: 8px;
  margin: 4px 0 18px;
  padding: 0 10px 0 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 8px 22px rgba(35, 34, 29, .06);
}
.search-bar svg { width: 21px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-bar input { min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 16px; }
.clear-search { width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--paper); color: var(--muted); font-size: 21px; }

.dictionary-grid, .dictionary-picker { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.dictionary-card {
  width: 100%;
  min-width: 0;
  min-height: 136px;
  display: flex;
  flex-direction: column;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 8px 16px rgba(48, 50, 43, .08), inset 0 1px 0 rgba(255,255,255,.8);
  transition: transform .15s, box-shadow .15s;
}
.dictionary-card:active { transform: translateY(2px); box-shadow: 0 3px 8px rgba(48,50,43,.08); }
.dictionary-image { width: 46px; height: 46px; display: block; }
.dictionary-card-heading, .dictionary-choice-heading { display: flex; align-items: center; gap: 9px; min-width: 0; }
.dictionary-card-heading .dictionary-image { flex: 0 0 auto; }
.dictionary-card-heading strong, .dictionary-choice-heading strong { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.dictionary-card small, .dictionary-choice small { margin-top: 4px; color: var(--muted); }
.dictionary-description { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dictionary-count { font-size: 12px; }
.dictionary-card.add { justify-content: center; align-items: center; gap: 8px; border-style: dashed; color: var(--muted); }
.dictionary-card.add b { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; font-size: 24px; font-weight: 400; }
.dictionary-card.add strong { margin: 0; font-size: 15px; }
.dictionary-card:nth-child(4n+1), .dictionary-choice:nth-child(4n+1) { background: var(--flash-soft); border-color: #f1d3cd; }
.dictionary-card:nth-child(4n+2), .dictionary-choice:nth-child(4n+2) { background: var(--blue-soft); border-color: #d4e2ea; }
.dictionary-card:nth-child(4n+3), .dictionary-choice:nth-child(4n+3) { background: var(--green-soft); border-color: #d5e6db; }
.dictionary-card:nth-child(4n), .dictionary-choice:nth-child(4n) { background: var(--gold-soft); border-color: #eadfbd; }
.dictionary-card.add { background: var(--card); border-color: var(--line); }

.page-title { min-height: 58px; display: flex; align-items: center; gap: 12px; }
.page-title h1 { flex: 1; margin: 0; font-family: "Noto Serif SC", "Yu Mincho", serif; font-size: 27px; }
.page-title > a:first-child {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(118, 118, 128, .12);
  color: #1d1d1f;
  box-shadow: none;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}
.page-title > a:first-child svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.page-title > a:first-child:hover { background: rgba(118, 118, 128, .2); }
.page-title > a:first-child:active { transform: scale(.92); background: rgba(118, 118, 128, .26); }
.page-title > a:first-child:focus-visible { outline: 3px solid rgba(0, 122, 255, .24); outline-offset: 2px; }
.compact-title { min-height: 46px; }
.text-button { color: var(--flash); font-size: 14px; font-weight: 600; }
.word-list { display: grid; min-width: 0; gap: 10px; }
.dictionary-choice { position: relative; width: 100%; min-width: 0; min-height: 130px; display: flex; flex-direction: column; padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: var(--card); }
.dictionary-choice .dictionary-image { width: 48px; height: 48px; }
.dictionary-choice-heading { padding-right: 30px; }
.dictionary-choice-heading .dictionary-image { width: 48px; height: 48px; flex: 0 0 auto; }
.dictionary-choice .save-dictionary { position: absolute; top: 5px; right: 4px; }
.save-dictionary, .favorite-button { width: 44px; height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 24px; }
.save-dictionary.active, .favorite-button.active { color: var(--flash); }

.result-summary { margin: 0 2px 12px; color: var(--muted); font-size: 13px; }
.word-card { position: relative; width: 100%; min-width: 0; min-height: 62px; display: flex; align-items: center; padding-right: 52px; border: 1px solid var(--line); border-left: 3px solid #efb2aa; border-radius: 14px; background: linear-gradient(145deg, #fff, #fbfaf7); box-shadow: 0 5px 12px rgba(48,50,43,.07), inset 0 1px 0 #fff; }
.word-card:nth-child(3n+2) { border-left-color: #a9c9d8; }
.word-card:nth-child(3n) { border-left-color: #aacbb7; }
.word-card > .favorite-button { position: absolute; top: 6px; right: 5px; }
.word-card.has-restore { padding-right: 66px; }
.word-card > .restore-button { position: absolute; top: 11px; right: 8px; min-width: 50px; min-height: 38px; border: 1px solid #aacbb7; border-radius: 10px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 600; }
.word-card > .restore-button:active { transform: translateY(1px); }
.word-card > .restore-button:disabled { opacity: .5; }
.word-card-link { flex: 1 1 auto; min-width: 0; padding: 11px 4px 11px 13px; }
.word-head { min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.word-head strong { flex: 0 1 55%; min-width: 0; overflow: hidden; font-family: "Yu Mincho", "Noto Serif JP", serif; font-size: 24px; text-overflow: ellipsis; white-space: nowrap; }
.word-head span { flex: 1 1 45%; min-width: 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.word-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.word-toolbar .result-summary { flex: 1; margin: 0; }
.word-toolbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.word-toolbar select { width: auto; min-height: 38px; padding: 0 28px 0 9px; font-size: 13px; }
.pagination { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-top: 14px; }
.pagination > button, .pagination form button { min-height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.pagination > button:disabled { opacity: .38; cursor: default; }
.pagination > span { text-align: center; color: var(--muted); font-size: 13px; }
.pagination form { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 7px; }
.pagination form label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.pagination input { width: 62px; min-height: 42px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); text-align: center; font-size: 16px; }

select { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); color: var(--ink); font-size: 16px; }
.primary-button { width: 100%; min-height: 48px; border: 0; border-radius: 12px; background: linear-gradient(180deg, #39423d, var(--ink)); color: white; box-shadow: 0 4px 0 #111512, 0 8px 15px rgba(31,33,30,.16); font-weight: 600; }
.primary-button:active { transform: translateY(3px); box-shadow: 0 1px 0 #111512; }
.word-view-card { position: relative; min-height: 390px; display: flex; flex-direction: column; justify-content: flex-start; margin-bottom: 14px; padding: 32px 22px 24px; border: 1px solid #d9d8d0; border-radius: 22px; background: linear-gradient(145deg, #fff, #faf8f2); box-shadow: 0 14px 30px rgba(42,46,40,.12), inset 0 1px 0 #fff; text-align: center; }
.word-card-menu-panel { position: absolute; right: 0; bottom: 66px; width: min(250px,calc(100vw - 32px)); padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.98); box-shadow: 0 12px 30px rgba(42,46,40,.18); text-align: left; }
.word-card-menu-panel[hidden] { display: none; }
.word-card-menu-panel button, .word-card-menu-panel a { width: 100%; min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.word-card-menu-panel button:hover, .word-card-menu-panel a:hover { background: var(--blue-soft); }
.word-card-menu-panel span { font-size: 14px; font-weight: 600; }
.word-card-menu-panel [data-admin-delete-word] { color: #c53030; }
.word-card-menu-panel small { flex: none; color: var(--muted); font-size: 10px; }
.word-card-menu-panel .is-placeholder { color: var(--muted); }
#word-detail { position: relative; }
.slash-source { opacity: 0; }
.slash-stage { position: absolute; top: 0; left: 0; z-index: 25; width: 100%; overflow: visible; pointer-events: none; }
.slash-stage::before { content: ""; position: absolute; top: 50%; left: -14%; z-index: 3; width: 128%; height: 4px; border-radius: 50%; background: white; box-shadow: 0 0 7px 2px #fff, 0 0 18px 6px rgba(229,72,63,.9); transform: rotate(-14deg) scaleX(0); transform-origin: left; animation: slash-line .3s cubic-bezier(.16,.8,.3,1) .04s forwards; }
.slash-stage::after { content: ""; position: absolute; inset: -8px; z-index: 2; border-radius: 24px; background: radial-gradient(ellipse at center,rgba(255,255,255,.75),rgba(255,255,255,0) 65%); opacity: 0; animation: slash-flash .28s ease-out .1s; }
.slash-half { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; }
.slash-upper { clip-path: polygon(0 0,100% 0,100% 37%,0 63%); animation: slash-upper .62s cubic-bezier(.2,.7,.2,1) .08s forwards; }
.slash-lower { clip-path: polygon(0 63%,100% 37%,100% 100%,0 100%); animation: slash-lower .62s cubic-bezier(.2,.7,.2,1) .08s forwards; }
.slash-sparks { position: absolute; top: 50%; left: 50%; z-index: 4; transform: rotate(-14deg); }
.slash-sparks i { --x: 70px; --y: -24px; position: absolute; width: 3px; height: 14px; border-radius: 50%; background: #ffd8a3; box-shadow: 0 0 7px #e5483f; opacity: 0; animation: slash-spark .45s ease-out .12s forwards; }
.slash-sparks i:nth-child(2) { --x: 42px; --y: 38px; animation-delay: .15s; }
.slash-sparks i:nth-child(3) { --x: -54px; --y: -36px; animation-delay: .1s; }
.slash-sparks i:nth-child(4) { --x: -76px; --y: 24px; animation-delay: .18s; }
.slash-sparks i:nth-child(5) { --x: 18px; --y: -58px; animation-delay: .2s; }
.slash-sparks i:nth-child(6) { --x: -12px; --y: 58px; animation-delay: .13s; }
.slash-seal { position: absolute; top: 43%; left: 50%; z-index: 5; color: var(--flash); font-family: "Yu Mincho", serif; font-size: 62px; line-height: 1; text-shadow: 0 2px 0 white, 0 0 18px rgba(229,72,63,.35); opacity: 0; transform: translate(-50%,-50%) scale(1.7) rotate(-7deg); animation: slash-seal .52s cubic-bezier(.2,.8,.2,1) .18s forwards; }
@keyframes slash-line { 45% { transform: rotate(-14deg) scaleX(1); } 100% { opacity: 0; transform: rotate(-14deg) scaleX(1); } }
@keyframes slash-flash { 35% { opacity: .6; } 100% { opacity: 0; } }
@keyframes slash-upper { 0%,25% { opacity: 1; transform: translate(0); } 70% { opacity: 1; transform: translate(12px,-13px) rotate(.5deg); } 100% { opacity: 0; transform: translate(16px,-17px) rotate(.7deg) scale(.985); } }
@keyframes slash-lower { 0%,25% { opacity: 1; transform: translate(0); } 70% { opacity: 1; transform: translate(-12px,14px) rotate(-.5deg); } 100% { opacity: 0; transform: translate(-16px,18px) rotate(-.7deg) scale(.985); } }
@keyframes slash-spark { 0% { opacity: 1; transform: translate(0) scaleY(.5); } 100% { opacity: 0; transform: translate(var(--x),var(--y)) scaleY(.1); } }
@keyframes slash-seal { 35% { opacity: 1; transform: translate(-50%,-50%) scale(.92) rotate(-7deg); } 100% { opacity: 0; transform: translate(-50%,-50%) scale(1.03) rotate(-7deg); } }
.word-view-card, .word-main, .word-meanings, .word-details, .meaning-heading, .meaning-heading > div, .example-list, .example-item { min-width: 0; max-width: 100%; }
.word-meanings { display: grid; gap: 4px; }
.word-details { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.word-details h3 { margin: 7px 0 5px; color: var(--flash); font-size: 18px; }
.word-details small { display: block; color: var(--muted); }
.meaning-heading { display: flex; align-items: center; justify-content: center; gap: 9px; }
.meaning-heading > span { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; font-size: 12px; }
.meaning-heading > div { display: flex; flex-wrap: wrap; gap: 5px; }
.meaning-heading small { padding: 3px 7px; border-radius: 12px; background: var(--blue-soft); color: var(--blue); font-size: 11px; }
.meaning-ja { margin: 0 0 14px; color: var(--muted); font-size: 15px; line-height: 1.75; }
.word-main { display: grid; grid-template-columns: minmax(0, 1fr); align-items: end; text-align: center; }
.word-main h2 { grid-column: 1 / -1; margin: 0; font-family: "Yu Mincho", serif; font-size: clamp(40px, 13vw, 60px); overflow-wrap: anywhere; }
.word-main p { grid-column: 1; margin: 8px 0 4px; color: var(--muted); font-size: 18px; overflow-wrap: anywhere; }
.example-list { display: grid; gap: 10px; text-align: left; }
.example-item { display: grid; grid-template-columns: minmax(0, 1fr) 42px; column-gap: 8px; padding: 12px 13px 11px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.word-details h3, .meaning-ja, .example-item p, .example-item small { overflow-wrap: anywhere; }
.example-item p { grid-column: 1; margin: 0 0 5px; font-size: 17px; line-height: 2.05; }
.example-item small { grid-column: 1; line-height: 1.5; }
ruby { overflow-wrap: anywhere; ruby-align: center; }
rt { color: var(--flash); font-size: .52em; font-weight: 500; }
.example-word-link { color: #396f8e; text-decoration: underline; text-decoration-color: #86afc5; text-decoration-thickness: 1.5px; text-underline-offset: 4px; border-radius: 3px; }
.example-word-link:active { color: var(--flash); background: var(--flash-soft); }
.word-actions { position: fixed; left: 50%; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 19; width: min(calc(100% - 32px), 428px); display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; padding: 8px 0; transform: translateX(-50%); background: linear-gradient(180deg, rgba(250,248,243,.25), var(--paper) 32%); }
.word-actions > button, .word-actions > .word-more-menu > button { width: 100%; min-height: 57px; display: grid; place-items: center; align-content: center; gap: 1px; border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 13px; background: linear-gradient(180deg, #fff, #f4f2ec); color: var(--ink); box-shadow: 0 4px 9px rgba(48,50,43,.07); font-size: 24px; }
.word-actions > button:active:not(:disabled), .word-actions > .word-more-menu > button:active { transform: translateY(2px); border-bottom-width: 1px; }
.word-actions > button:disabled { opacity: .35; cursor: default; }
.word-actions > button small, .word-actions > .word-more-menu > button small { color: var(--muted); font-size: 11px; }
.word-actions > button b, .word-actions > .word-more-menu > button b { font-size: 22px; font-weight: 500; }
.word-actions > button.active { border-color: #efb2aa; background: var(--flash-soft); color: var(--flash); }
.word-actions .eliminate-button { color: #8e453f; }
.word-actions .eliminate-button.active { border-color: #aacbb7; background: var(--green-soft); color: var(--green); }
.word-more-menu { position: relative; min-width: 0; }
.word-more-button b { width: 24px; height: 24px; }
.word-more-button svg { width: 100%; height: 100%; display: block; fill: currentColor; }
.word-more-button[aria-expanded="true"] { border-color: #efb2aa; background: var(--flash-soft); color: var(--flash); }
.is-eliminating .word-actions button { pointer-events: none; }
/* The header and word scroll together; only the two bottom menus stay fixed. */
body[data-page="word-detail"] main { padding-bottom: calc(130px + env(safe-area-inset-bottom)); }
body[data-page="word-detail"] .word-actions { position: fixed; bottom: calc(62px + env(safe-area-inset-bottom)); }
body[data-page="word-detail"] .bottom-nav { position: fixed; left: 50%; bottom: 0; width: min(100%, 460px); height: calc(56px + env(safe-area-inset-bottom)); transform: translateX(-50%); border-radius: 0; }

.profile-card { display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 12px; padding: 18px; border: 1px solid #d4e2ea; border-radius: 18px; background: var(--blue-soft); }
.avatar { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; font-size: 21px; }
.profile-card strong, .profile-card small { display: block; }
.profile-card small { margin-top: 3px; color: var(--muted); }
.role-tag { padding: 4px 8px; border-radius: 20px; background: var(--flash-soft); color: var(--flash); font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stats-grid div, .stats-grid .stat-card { padding: 14px 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); text-align: center; }
.stats-grid strong, .stats-grid small { display: block; }
.stats-grid strong { font-size: 21px; }
.stats-grid small { margin-top: 3px; color: var(--muted); }
.stats-grid > :nth-child(1) { background: var(--flash-soft); border-color: #f1d3cd; }
.stats-grid > :nth-child(2) { background: var(--green-soft); border-color: #d5e6db; }
.stats-grid > :nth-child(3) { background: var(--gold-soft); border-color: #eadfbd; }
.user-stats { grid-template-columns: 1fr 1fr; }
.user-stats .favorite-stat { background: var(--green-soft); border-color: #d5e6db; }
.user-stats .killed-stat { background: var(--gold-soft); border-color: #eadfbd; }
.stat-card { box-shadow: 0 5px 11px rgba(48,50,43,.06); transition: transform .15s, box-shadow .15s; }
.stat-card:active { transform: translateY(2px); box-shadow: 0 2px 5px rgba(48,50,43,.05); }
.count-summary { margin: -2px 2px 14px; color: var(--muted); font-size: 14px; }
.count-summary strong { margin: 0 3px; color: var(--flash); font-size: 18px; }
.menu-row { min-height: 54px; display: flex; align-items: center; justify-content: space-between; margin: 12px 0; padding: 0 16px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(145deg, #fff, #f8f7f2); box-shadow: 0 6px 13px rgba(48,50,43,.07); }
.menu-row b { color: var(--muted); font-size: 22px; }
.auth-panel, .admin-panel { padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 16px; padding: 4px; border-radius: 12px; background: var(--paper); }
.auth-tabs button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.auth-tabs button.active { background: var(--card); color: var(--ink); box-shadow: 0 2px 8px rgba(35,34,29,.08); }
.auth-form, .stack-form { display: grid; gap: 13px; }
.auth-form label, .stack-form label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.auth-form input, .stack-form input, .stack-form textarea, .form-section select { width: 100%; min-height: 45px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font-size: 16px; }
.stack-form textarea { resize: vertical; font-family: inherit; font-size: 16px; }
.stack-form textarea[name="metadata"] { font-family: ui-monospace, monospace; font-size: 13px; }
.form-message { min-height: 20px; margin: 12px 0 0; color: var(--flash); font-size: 13px; }
.form-hint { color: var(--muted); font-size: 11px; }
.secondary-button { min-height: 46px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); color: var(--ink); }
.full-button { width: 100%; margin-top: 16px; }
.profile-form { padding-bottom: 8px; }
.form-section { display: grid; gap: 13px; padding: 16px; border: 1px solid var(--line); border-radius: 17px; background: var(--card); box-shadow: 0 6px 14px rgba(48,50,43,.06); }
.form-section h2 { margin: 0; font-size: 17px; }
.form-section p { margin: -5px 0 0; color: var(--muted); font-size: 12px; }
.form-section input:disabled { color: var(--muted); background: #f0eee8; }
.admin-panel { margin-bottom: 12px; }
.word-pre-panel { padding: 12px 16px; }
.word-pre-panel h2 { margin: 0 0 8px; font-size: 18px; }
.word-pre-panel h2 small { color: var(--muted); font-size: 13px; font-weight: 400; }
.word-pre-panel .stack-form { gap: 8px; }
.word-pre-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.word-pre-actions > button { width: 100%; min-width: 0; min-height: 40px; padding: 7px 4px; font-size: 13px; white-space: nowrap; }
.admin-export-card { display: grid; grid-template-columns: 50px minmax(0,1fr) auto; align-items: center; gap: 12px; margin-bottom: 12px; padding: 14px; border: 1px solid #cbded3; border-radius: 18px; background: linear-gradient(135deg,#f7fcf8,#e9f4ed); box-shadow: 0 8px 18px rgba(58,95,72,.09); }
.admin-export-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 15px; background: var(--green); color: white; box-shadow: 0 5px 12px rgba(54,112,77,.22); }
.admin-export-icon svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.admin-pending-link { display: flex; align-items: center; gap: 14px; min-height: 82px; margin: 14px 0; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: 0 3px 12px rgba(16, 61, 91, .06); transition: border-color .16s ease, box-shadow .16s ease; }
.admin-pending-link .admin-export-icon { flex: none; }
.admin-pending-link .admin-export-copy { flex: 1; }
.admin-pending-arrow { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--blue); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.admin-pending-link:hover { border-color: var(--blue); box-shadow: 0 5px 16px rgba(16, 61, 91, .12); }
.admin-pending-link:active { background: var(--blue-soft); }
.admin-pending-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.admin-export-copy { min-width: 0; }
.admin-export-copy strong, .admin-export-copy small { display: block; }
.admin-export-copy strong { font-size: 15px; }
.admin-export-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.admin-export-button { min-height: 42px; padding: 0 14px; border: 0; border-radius: 12px; background: linear-gradient(180deg,#4f8764,#376d4c); color: white; box-shadow: 0 3px 0 #28553a,0 6px 12px rgba(54,112,77,.17); font-weight: 600; white-space: nowrap; }
.admin-export-button:active { transform: translateY(2px); box-shadow: 0 1px 0 #28553a; }
.admin-export-button:disabled { opacity: .55; cursor: wait; }
.admin-file-picker { position: relative; min-height: 66px; display: flex !important; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px dashed #9ebdad; border-radius: 13px; background: var(--green-soft); color: var(--ink) !important; cursor: pointer; }
.admin-file-picker::before { content: "＋"; flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: white; color: var(--green); font-size: 22px; }
.admin-file-picker span { flex: 1; font-weight: 600; }
.admin-file-picker small { max-width: 42%; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.admin-file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.admin-import-submit { display: inline-flex; align-items: center; justify-content: center; gap: 9px; }
.admin-import-submit.is-loading::before { content: ""; width: 17px; height: 17px; flex: none; border: 2px solid rgba(255,255,255,.4); border-top-color: white; border-radius: 50%; animation: admin-import-spin .7s linear infinite; }
.admin-import-submit:disabled { opacity: .58; cursor: wait; transform: none; box-shadow: 0 2px 0 #111512,0 5px 10px rgba(31,33,30,.1); }
.admin-import-result { margin: 0; padding: 11px 13px; border: 1px solid #b9d7c4; border-radius: 11px; background: var(--green-soft); color: #28553a; font-size: 14px; font-weight: 600; line-height: 1.5; }
@keyframes admin-import-spin { to { transform: rotate(360deg); } }
.admin-panel summary { cursor: pointer; font-weight: 600; }
.admin-panel[open] summary { margin-bottom: 15px; }
.admin-word-filters { display: grid; grid-template-columns: minmax(110px,.7fr) minmax(0,1.3fr); gap: 10px; margin-bottom: 12px; }
.admin-word-filters label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.admin-word-filters input { width: 100%; min-width: 0; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); color: var(--ink); font-size: 15px; }
.admin-user-search { margin-bottom: 12px; }
.admin-user-search label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.admin-user-search input { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); color: var(--ink); font-size: 15px; }
.admin-user-row { padding: 12px 8px; }
.admin-user-info { min-width: 0; }
.admin-user-info strong { margin-right: 6px; }
.admin-user-info em { padding: 2px 6px; border-radius: 10px; background: var(--flash-soft); color: var(--flash); font-size: 10px; font-style: normal; }
.admin-user-info small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-user-actions { display: flex; gap: 6px; }
.admin-user-actions button { min-height: 36px; padding: 0 9px; border-radius: 9px; font-size: 12px; }
.user-delete-button { border: 1px solid #e2aaa5; background: var(--flash-soft); color: #a3322d; }
.user-reset-button { border: 1px solid #d4e2ea; background: var(--blue-soft); color: var(--blue); }
.admin-user-actions button:disabled { opacity: .45; cursor: default; }
.admin-dictionary-list { display: grid; gap: 12px; }
.admin-dictionary-item { padding: 15px; border: 1px solid var(--line); border-radius: 17px; background: var(--card); box-shadow: 0 6px 14px rgba(48,50,43,.06); }
.admin-dictionary-heading { width: 100%; display: flex; align-items: center; gap: 12px; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.admin-dictionary-heading .dictionary-image { width: 48px; height: 48px; }
.admin-dictionary-text, .admin-dictionary-text strong, .admin-dictionary-text small { display: block; min-width: 0; }
.admin-dictionary-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-dictionary-text small { margin-top: 3px; color: var(--muted); }
.admin-dictionary-edit { display: none; padding-top: 13px; border-top: 1px solid var(--line); }
.admin-dictionary-item.expanded .admin-dictionary-heading { margin-bottom: 14px; }
.admin-dictionary-item.expanded .admin-dictionary-edit { display: grid; }
.admin-dictionary-edit .secondary-button { width: 100%; }
@media (max-width: 390px) {
  .admin-export-card { grid-template-columns: 44px minmax(0,1fr); }
  .admin-export-icon { width: 44px; height: 44px; }
  .admin-export-button { grid-column: 1 / -1; width: 100%; }
}
.compact-list { display: grid; gap: 7px; }
.compact-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.compact-row small { color: var(--muted); }
.admin-word-row { padding: 12px 8px; border-radius: 10px; transition: background .15s, transform .15s; }
.admin-word-row > span, .admin-word-row strong, .admin-word-row small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-word-row strong, .admin-word-row small { display: block; }
.admin-word-row:hover { background: var(--blue-soft); }
.admin-word-row:active { transform: translateY(1px); }
.admin-word-row > b { color: var(--blue); font-size: 24px; font-weight: 400; }
.admin-edit-form { padding-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-edit-form fieldset { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--card); box-shadow: 0 6px 14px rgba(48,50,43,.06); }
.admin-edit-form legend { padding: 0 5px; font-weight: 600; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check-grid label { min-height: 40px; display: flex; align-items: center; gap: 7px; padding: 7px 9px; border-radius: 9px; background: var(--paper); color: var(--ink); }
.check-grid input { width: 18px; min-height: 18px; accent-color: var(--flash); }
.example-editor { display: grid; gap: 11px; margin-bottom: 11px; }
.meaning-editor { display: grid; gap: 13px; margin-bottom: 12px; }
.meaning-edit-row { display: grid; gap: 11px; padding: 13px; border: 1px solid #d4e2ea; border-radius: 13px; background: var(--blue-soft); }
.meaning-edit-heading, .meaning-example-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.meaning-edit-heading strong { font-size: 15px; }
.remove-meaning { min-height: 34px; padding: 0 9px; border: 0; border-radius: 9px; background: var(--flash-soft); color: var(--flash); font-size: 12px; }
.field-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.meaning-pos label { background: var(--card); }
.meaning-example-heading { margin-top: 2px; }
.meaning-example-heading .text-button { border: 0; background: transparent; }
.example-edit-row { position: relative; display: grid; gap: 9px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.example-edit-row label { padding-right: 31px; }
.remove-example { position: absolute; top: 7px; right: 7px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--flash-soft); color: var(--flash); font-size: 22px; }
.danger-button { min-height: 46px; border: 1px solid #e2aaa5; border-radius: 11px; background: var(--flash-soft); color: #a3322d; }

.empty { padding: 42px 18px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); text-align: center; }
.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 20;
  width: 100%;
  height: calc(66px + env(safe-area-inset-bottom));
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 -8px 22px rgba(42,46,40,.08);
}
.bottom-nav a { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; }
.bottom-nav span { font-size: 21px; line-height: 1; }
body[data-page="home"] [data-nav="home"], body[data-page="favorites"] [data-nav="favorites"], body[data-page="me"] [data-nav="me"], body[data-page="profile"] [data-nav="me"], body[data-page="killed"] [data-nav="me"], body[data-page="admin"] [data-nav="me"], body[data-page="admin-users"] [data-nav="me"], body[data-page="admin-dictionaries"] [data-nav="me"], body[data-page="admin-words"] [data-nav="me"], body[data-page="admin-word"] [data-nav="me"] { color: var(--flash); font-weight: 600; }
body[data-page="home"] [data-nav="home"] span, body[data-page="favorites"] [data-nav="favorites"] span, body[data-page="me"] [data-nav="me"] span, body[data-page="profile"] [data-nav="me"] span, body[data-page="killed"] [data-nav="me"] span, body[data-page="admin"] [data-nav="me"] span, body[data-page="admin-users"] [data-nav="me"] span, body[data-page="admin-dictionaries"] [data-nav="me"] span, body[data-page="admin-words"] [data-nav="me"] span, body[data-page="admin-word"] [data-nav="me"] span { width: 30px; height: 26px; display: grid; place-items: center; border-radius: 10px; background: var(--flash-soft); }
.toast { position: fixed; left: 50%; bottom: 78px; z-index: 30; transform: translate(-50%, 16px); padding: 9px 14px; border-radius: 9px; background: var(--ink); color: white; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 600px) {
  .app-frame { min-height: calc(100svh - 40px); margin: 20px auto; border-radius: 28px; box-shadow: 0 18px 55px rgba(35, 34, 29, .13); }
  .bottom-nav { border-radius: 0 0 28px 28px; }
  .word-actions { bottom: calc(86px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
}

@media (max-width: 350px) {
  main { padding-inline: 12px; }
  .topbar { padding-inline: 14px; }
  .dictionary-grid, .dictionary-picker { gap: 8px; }
  .dictionary-card, .dictionary-choice { min-height: 126px; padding: 12px; }
  .admin-user-row { grid-template-columns: 1fr; }
  .admin-user-actions { justify-content: flex-end; }
}

/* Apple-style system theme */
body { background: #e5e5ea; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(0, 122, 255, .24); outline-offset: 2px; }

.app-frame { background: var(--bg); }
.topbar { height: 72px; padding: 0 18px; }
.brand { gap: 10px; }
.brand-icon { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(145deg, #3a3a3c, #111); box-shadow: 0 2px 6px rgba(0, 0, 0, .18); }
.brand-icon svg { width: 24px; }
.brand strong { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.brand small { font-size: 10px; letter-spacing: .03em; }
main { padding: 0 16px 28px; }

.page-title { min-height: 60px; gap: 10px; }
.page-title h1 { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Hiragino Sans", "Noto Sans SC", sans-serif; font-size: 28px; font-weight: 750; letter-spacing: -.035em; }
.page-title > a:first-child { background: rgba(118, 118, 128, .12); color: var(--ink); }
.page-title > a:first-child:hover { background: rgba(118, 118, 128, .2); }

.search-bar { height: 50px; margin: 4px 0 18px; border: 0; border-radius: 14px; background: rgba(118, 118, 128, .12); box-shadow: none; }
.search-bar:focus-within { background: var(--card); }
.search-bar svg { stroke: #8e8e93; }
.search-bar input { font-size: 16px; }
.search-bar input:focus { outline: none; background: transparent; }
.clear-search { background: #8e8e93; color: #fff; font-size: 17px; }

.dictionary-grid, .dictionary-picker { gap: 12px; }
.dictionary-card, .dictionary-choice { border: .5px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }
.dictionary-card:nth-child(n), .dictionary-choice:nth-child(n) { background: var(--card); border-color: var(--line); }
.dictionary-card, .dictionary-choice { min-height: 134px; padding: 15px; }
.dictionary-card { transition: transform .18s ease, box-shadow .18s ease; }
.dictionary-card:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(0, 0, 0, .08); }
.dictionary-card:active { transform: scale(.975); box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }
.dictionary-card-heading strong, .dictionary-choice-heading strong { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.dictionary-card.add { border: .5px solid var(--line); background: rgba(255, 255, 255, .62); }
.dictionary-card.add b { width: 36px; height: 36px; background: var(--blue); font-size: 22px; }

.heart-icon { width: 25px; height: 25px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.heart-icon.filled { fill: currentColor; }
.save-dictionary, .favorite-button { display: grid; place-items: center; color: #8e8e93; }
.save-dictionary.active, .favorite-button.active { color: var(--flash); }

.word-card { min-height: 64px; border: .5px solid var(--line); border-left-width: .5px; border-radius: 15px; background: var(--card); box-shadow: 0 1px 2px rgba(0, 0, 0, .045); transition: transform .16s ease, background .16s ease; }
.word-card:nth-child(n) { border-left-color: var(--line); }
.word-card:hover { background: #fafafa; }
.word-card:active { transform: scale(.985); background: #f7f7f8; }
.word-head strong { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.word-head span { color: var(--muted); }
.word-card > .restore-button { border: 0; border-radius: 10px; background: rgba(0, 122, 255, .1); color: var(--blue); }

select, .auth-form input, .stack-form input, .stack-form textarea, .form-section select, .admin-word-filters input, .admin-user-search input, .pagination input { border: .5px solid var(--line); border-radius: 11px; background-color: rgba(118, 118, 128, .1); color: var(--ink); box-shadow: none; }
input:focus, select:focus, textarea:focus { border-color: rgba(0, 122, 255, .48); background-color: var(--card); outline: 3px solid rgba(0, 122, 255, .12); }
.word-toolbar select { min-height: 36px; border: 0; border-radius: 10px; background-color: rgba(118, 118, 128, .12); color: var(--ink); }

.primary-button, .admin-export-button { min-height: 48px; border: 0; border-radius: 13px; background: var(--blue); color: #fff; box-shadow: none; font-weight: 650; transition: transform .12s ease, opacity .12s ease, background .12s ease; }
.primary-button:hover, .admin-export-button:hover { background: #0071e3; }
.primary-button:active, .admin-export-button:active { transform: scale(.98); box-shadow: none; opacity: .86; }
.secondary-button { border: .5px solid var(--line); border-radius: 12px; background: var(--card); color: var(--blue); font-weight: 600; }
.danger-button, .user-delete-button { border: 0; background: rgba(255, 59, 48, .1); color: var(--flash); }
.user-reset-button { border: 0; background: rgba(0, 122, 255, .1); color: var(--blue); }
.text-button { color: var(--blue); }

.word-view-card { border: .5px solid var(--line); border-radius: 24px; background: var(--card); box-shadow: 0 2px 10px rgba(0, 0, 0, .055); }
.word-main h2 { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif; font-weight: 700; letter-spacing: -.04em; }
.word-details { border-top-color: var(--line); }
.word-details h3 { color: var(--ink); font-weight: 700; letter-spacing: -.02em; }
.meaning-heading > span { background: var(--blue); }
.meaning-heading small { background: rgba(0, 122, 255, .1); color: var(--blue); }
.example-item { border: 0; border-radius: 14px; background: var(--bg); }
/* Audio controls are temporarily commented out; give their space to the text. */
.example-item { grid-template-columns: minmax(0, 1fr); }
.example-word-link { color: var(--blue); text-decoration-color: rgba(0, 122, 255, .45); }

.word-actions { gap: 6px; padding: 4px 8px; border: .5px solid rgba(60, 60, 67, .16); border-radius: 16px; background: rgba(249, 249, 249, .82); box-shadow: 0 8px 26px rgba(0, 0, 0, .12); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); }
.word-actions > button, .word-actions > .word-more-menu > button { min-height: 44px; border: 0; border-radius: 11px; background: transparent; box-shadow: none; color: var(--ink); font-size: 22px; }
.word-actions > button:hover, .word-actions > .word-more-menu > button:hover { background: rgba(118, 118, 128, .1); }
.word-actions > button:active:not(:disabled), .word-actions > .word-more-menu > button:active { transform: scale(.94); border-bottom-width: 0; }
.word-actions > button.active, .word-more-button[aria-expanded="true"] { border: 0; background: rgba(255, 59, 48, .1); color: var(--flash); }
.word-actions .eliminate-button { color: var(--flash); }
.word-actions .eliminate-button.active { border: 0; background: rgba(52, 199, 89, .12); color: #248a3d; }
.word-actions > button b svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.word-card-menu-panel { border: .5px solid rgba(60, 60, 67, .18); border-radius: 16px; background: rgba(250, 250, 250, .92); box-shadow: 0 16px 44px rgba(0, 0, 0, .18); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); }
.word-card-menu-panel button:hover, .word-card-menu-panel a:hover { background: rgba(118, 118, 128, .1); }

.profile-card, .auth-panel, .admin-panel, .form-section, .admin-dictionary-item, .admin-edit-form fieldset { border: .5px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .045); }
.profile-card { padding: 16px; }
.avatar { background: linear-gradient(145deg, #0a84ff, #0066d6); font-weight: 650; }
.role-tag { background: rgba(0, 122, 255, .1); color: var(--blue); }
.stats-grid { gap: 10px; }
.stats-grid div, .stats-grid .stat-card, .stats-grid > :nth-child(n), .user-stats .favorite-stat, .user-stats .killed-stat { border: .5px solid var(--line); border-radius: 15px; background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .04); }
.stat-card:active { transform: scale(.97); box-shadow: none; }
.count-summary strong { color: var(--blue); }
.menu-row { min-height: 54px; margin: 10px 0; border: .5px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: none; }
.menu-row b, .admin-word-row > b { width: 20px; height: 20px; color: #c7c7cc; }
.menu-row b svg, .admin-word-row > b svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.auth-tabs { border-radius: 10px; background: rgba(118, 118, 128, .12); }
.auth-tabs button { border-radius: 8px; }
.auth-tabs button.active { box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.form-section input:disabled { background: rgba(118, 118, 128, .08); }

.admin-export-card { border: .5px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .045); }
.admin-export-icon { border-radius: 13px; background: var(--blue); box-shadow: none; }
.admin-file-picker { border: 1px dashed rgba(0, 122, 255, .4); border-radius: 14px; background: rgba(0, 122, 255, .06); }
.admin-file-picker::before { background: var(--card); color: var(--blue); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.admin-import-result { border: 0; background: rgba(52, 199, 89, .1); color: #248a3d; }
.admin-word-row { border-radius: 12px; }
.admin-word-row:hover { background: rgba(118, 118, 128, .08); }
.meaning-edit-row { border: .5px solid var(--line); border-radius: 15px; background: var(--bg); }
.example-edit-row, .check-grid label { border-color: var(--line); background: rgba(118, 118, 128, .08); }
.check-grid input { accent-color: var(--blue); }
.remove-meaning, .remove-example { background: rgba(255, 59, 48, .1); color: var(--flash); }

.pagination > button, .pagination form button { min-height: 40px; border: 0; border-radius: 11px; background: var(--card); color: var(--blue); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }
.empty { border: 0; border-radius: 16px; background: rgba(118, 118, 128, .08); }
.toast { bottom: 82px; padding: 10px 15px; border-radius: 12px; background: rgba(28, 28, 30, .9); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }

.bottom-nav { height: calc(68px + env(safe-area-inset-bottom)); border-top: .5px solid rgba(60, 60, 67, .2); background: rgba(249, 249, 249, .86); box-shadow: none; -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); }
.bottom-nav a { gap: 3px; color: #8e8e93; font-size: 10px; font-weight: 500; }
.bottom-nav span { width: 26px; height: 26px; display: grid; place-items: center; background: transparent !important; }
.bottom-nav svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body[data-page="home"] [data-nav="home"], body[data-page="favorites"] [data-nav="favorites"], body[data-page="me"] [data-nav="me"], body[data-page="profile"] [data-nav="me"], body[data-page="killed"] [data-nav="me"], body[data-page="admin"] [data-nav="me"], body[data-page="admin-users"] [data-nav="me"], body[data-page="admin-dictionaries"] [data-nav="me"], body[data-page="admin-words"] [data-nav="me"], body[data-page="admin-word"] [data-nav="me"] { color: var(--blue); font-weight: 600; }
body[data-page="home"] [data-nav="home"] svg, body[data-page="favorites"] [data-nav="favorites"] svg, body[data-page="me"] [data-nav="me"] svg, body[data-page="profile"] [data-nav="me"] svg, body[data-page="killed"] [data-nav="me"] svg, body[data-page="admin"] [data-nav="me"] svg, body[data-page="admin-users"] [data-nav="me"] svg, body[data-page="admin-dictionaries"] [data-nav="me"] svg, body[data-page="admin-words"] [data-nav="me"] svg, body[data-page="admin-word"] [data-nav="me"] svg { stroke-width: 2.2; }

@media (min-width: 600px) {
  .app-frame { border: .5px solid rgba(60, 60, 67, .16); border-radius: 32px; box-shadow: 0 24px 70px rgba(0, 0, 0, .14); }
  .bottom-nav { border-radius: 0 0 32px 32px; }
}

@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --paper: #000; --card: #1c1c1e; --ink: #f5f5f7; --muted: #98989d; --line: rgba(84, 84, 88, .65); --flash-soft: rgba(255, 69, 58, .14); --green-soft: rgba(48, 209, 88, .13); --blue: #0a84ff; --blue-soft: rgba(10, 132, 255, .14); --gold-soft: rgba(255, 159, 10, .14); }
  html, body { background: #1c1c1e; }
  .brand-icon { background: linear-gradient(145deg, #48484a, #222); }
  .dictionary-card:hover, .word-card:hover { background: #242426; }
  .word-card:active { background: #2c2c2e; }
  .word-actions, .bottom-nav { background: rgba(28, 28, 30, .82); }
  .word-card-menu-panel { background: rgba(36, 36, 38, .94); }
  .search-bar:focus-within, input:focus, select:focus, textarea:focus { background-color: #242426; }
  .clear-search { background: #636366; }
  .menu-row b, .admin-word-row > b { color: #636366; }
}
/* Shared landscape stays fixed behind every page, including mobile scrolling. */
html { background: #75acc9; }
body { background: transparent; isolation: isolate; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: #75acc9 var(--landscape, none) center center / cover no-repeat;
}
.app-frame { background: rgba(242, 248, 252, .76); }
@media (prefers-color-scheme: dark) {
  html { background: #19394e; }
  body::before {
    background-image: linear-gradient(rgba(8, 25, 42, .38), rgba(8, 25, 42, .38)), var(--landscape, none);
  }
  .app-frame { background: rgba(15, 27, 39, .82); }
}
/* Glacier palette: snow-white surfaces, alpine blue controls, warm sunset accents. */
:root {
  --bg: #e8f3f8;
  --paper: rgba(237, 246, 250, .78);
  --card: rgba(250, 254, 255, .84);
  --ink: #193c53;
  --muted: #567387;
  --line: rgba(67, 124, 156, .21);
  --blue: #226d9b;
  --blue-soft: rgba(224, 239, 248, .78);
  --green: #368c96;
  --green-soft: #e0f2f2;
  --gold-soft: #fff1df;
  --flash: #c84449;
  --flash-soft: #fff0ef;
}
.app-frame { background: rgba(225, 241, 250, .65); border-color: rgba(235, 251, 255, .7); box-shadow: 0 24px 70px rgba(16, 61, 91, .18); }
.brand { gap: 11px; }
.brand-icon { width: 43px; height: 43px; border: 1px solid rgba(241, 253, 255, .8); border-radius: 15px; background: linear-gradient(145deg, #70b6cc, #24678e); box-shadow: 0 4px 12px rgba(26, 88, 127, .22); }
.brand-icon svg { width: 35px; height: 35px; fill: none; stroke: #f2fcff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand-icon .brand-mountain { fill: #b9e2ed; }
.brand-icon .brand-snow { fill: #fff; stroke: none; }
.brand-icon .brand-bowl { fill: #f4fbfc; stroke: #e4f4f9; }
.brand-icon .brand-smile { stroke: #317794; }
.brand-icon .brand-chopsticks { stroke: #f9ddbd; stroke-width: 2; }
.brand strong { color: var(--ink); letter-spacing: .025em; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .06em; }
.search-bar, .auth-tabs { background: rgba(111, 169, 196, .15); }
.search-bar svg { stroke: var(--muted); }
.dictionary-card, .dictionary-choice, .word-card, .word-view-card, .auth-panel, .admin-panel, .form-section, .admin-dictionary-item, .menu-row {
  border-color: var(--line);
  box-shadow: 0 4px 16px rgba(36, 89, 119, .065);
}
.dictionary-card:hover, .dictionary-choice:hover, .word-card:hover { background: rgba(237, 248, 252, .9); }
.admin-word-list-panel { padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: rgba(245, 251, 254, .9); box-shadow: 0 4px 18px rgba(36, 89, 119, .08); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.admin-word-list-panel .admin-word-row:last-child { border-bottom: 0; }
.meaning-edit-row { background: var(--paper); }
.primary-button, .auth-form button, .stack-form > button[type="submit"], .admin-export-button {
  background: linear-gradient(135deg, #3e96ba, #246b9b);
  color: #fff;
  box-shadow: 0 4px 12px rgba(35, 105, 151, .18);
}
.avatar, .admin-export-icon { background: linear-gradient(145deg, #64a9c5, #286a97); }
.auth-form input, .stack-form input, .stack-form textarea, .form-section select { border-color: var(--line); background: var(--paper); }
.word-actions, .bottom-nav { background: rgba(232, 246, 252, .91); border-color: var(--line); }
.bottom-nav a { color: var(--muted); }
.word-card-menu-panel { background: rgba(240, 249, 253, .96); border-color: var(--line); }
.meaning-heading small, .role-tag, .user-reset-button { background: var(--blue-soft); color: var(--blue); }
.empty, .example-edit-row, .check-grid label { background: rgba(133, 184, 209, .13); }
.admin-import-result { background: var(--blue-soft); color: var(--blue); }
.toast {
  max-width: min(420px, calc(100vw - 32px));
  width: max-content;
  bottom: calc(82px + env(safe-area-inset-bottom));
  border: 1px solid rgba(255, 255, 255, .3);
  background: #236caa;
  color: #fff;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 26px rgba(21, 59, 87, .22);
}
.toast[data-type="error"] { background: #c73540; color: #fff; }
.toast[data-type="warning"] { background: #f4ca4f; color: #4c3604; }
.toast[data-type="info"] { background: #236caa; color: #fff; }
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #132c40; --paper: rgba(23, 50, 71, .78); --card: rgba(24, 48, 66, .84);
    --ink: #e6f4fc; --muted: #a2c1d4; --line: rgba(148, 202, 226, .23);
    --blue: #80c8ef; --blue-soft: #214860; --green: #6ac1c6; --green-soft: #21484e;
    --gold-soft: #4b3e30; --flash: #ff9193; --flash-soft: #4c2c39;
  }
  .app-frame { background: rgba(13, 36, 54, .77); border-color: var(--line); }
  .admin-word-list-panel { background: rgba(20, 43, 60, .92); }
  .dictionary-card:hover, .dictionary-choice:hover, .word-card:hover, .word-card:active { background: #25495f; }
  .word-actions, .bottom-nav, .word-card-menu-panel { background: rgba(20, 46, 65, .95); }
  .search-bar:focus-within, input:focus, select:focus, textarea:focus { background-color: #203f55; }
}

.brand-icon { flex: 0 0 43px; border: 0; background: transparent; box-shadow: none; }
.brand-icon img { display: block; width: 100%; height: 100%; object-fit: contain; }
.bottom-nav a[aria-current="page"] { color: var(--blue); font-weight: 600; }
html, .app-frame > main { scrollbar-width: none; }
html::-webkit-scrollbar, .app-frame > main::-webkit-scrollbar { display: none; }
@media (min-width: 600px) {
  .app-frame { height: calc(100svh - 40px); overflow: clip; }
  .app-frame > .topbar { flex-shrink: 0; }
  .app-frame > main { min-height: 0; overflow-y: auto; }
  .app-frame > .bottom-nav,
  body[data-page="word-detail"] .app-frame > .bottom-nav {
    position: static;
    width: 100%;
    transform: none;
    border-radius: 0 0 32px 32px;
  }
  body[data-page="word-detail"] .word-actions {
    bottom: calc(82px + env(safe-area-inset-bottom));
  }
  body[data-page="word-detail"] .app-frame > main { padding-bottom: 72px; }
}
.word-card.read-only { padding-right: 0; }
.word-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.word-actions.signed-in { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.nihongo-dictionary-entry { position: relative; display: grid; min-width: 0; }
.nihongo-dictionary-entry:has(.save-dictionary) .dictionary-card { padding-right: 36px; }
.nihongo-dictionary-entry .save-dictionary { position: absolute; top: 8px; right: 6px; }
[hidden] { display: none !important; }
#reset-password-dialog { width: min(90vw, 360px); border: 1px solid var(--line); border-radius: 18px; padding: 18px; background: var(--card); color: var(--ink); }
#reset-password-dialog::backdrop { background: rgb(0 0 0 / 40%); }
