:root {
  --page: #f5f2eb;
  --surface: #fffdf8;
  --surface-soft: #fbfaf6;
  --ink: #252525;
  --muted: #716d65;
  --line: #d9d3c7;
  --accent: #28527a;
  --accent-dark: #1e3e5d;
  --accent-soft: #edf2f5;
  --mint: #3f705d;
  --mint-soft: #edf4ef;
  --amber: #9a6b2e;
  --amber-soft: #f8f0df;
  --red: #9e4944;
  --red-soft: #f8ecea;
  --shadow-sm: 0 3px 12px rgba(56, 49, 38, .055);
  --shadow-lg: 0 10px 25px rgba(56, 49, 38, .10);
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { min-width: 320px; margin: 0; background: var(--page); }
body::before, body::after { display: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid rgba(40, 82, 122, .55); outline-offset: 2px; }
.paper-texture { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .34; background-image: linear-gradient(rgba(80, 70, 54, .035) 1px, transparent 1px); background-size: 100% 9px; }
.app-shell { max-width: 1240px; margin: 0 auto; padding: 0 32px 54px; }
.site-header { min-height: 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { position: relative; width: 38px; height: 40px; display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; padding: 0 9px; overflow: hidden; border: 1px solid #1e3e5d; border-radius: 3px 3px 8px 3px; background: var(--accent); box-shadow: 3px 3px 0 rgba(40, 82, 122, .12); }
.brand-mark::after { content: ""; position: absolute; top: 0; right: 0; width: 12px; height: 12px; background: #b8c9d7; clip-path: polygon(0 0, 100% 100%, 0 100%); }
.brand-mark i { display: block; height: 2px; background: #fff; border-radius: 0; }
.brand-mark i:nth-child(2) { width: 14px; }
.brand-name { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 1.32rem; font-weight: 700; letter-spacing: -.035em; line-height: 1; }
.brand-caption { display: block; margin-top: 5px; color: var(--muted); font-size: .58rem; letter-spacing: .1em; text-transform: uppercase; }
.header-note { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .75rem; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: #b38445; box-shadow: none; }

.workspace { display: grid; grid-template-columns: minmax(290px, 330px) minmax(0, 1fr); gap: 34px; padding-top: 36px; }
.panel, .main-panel { min-width: 0; }
.entry-panel { position: sticky; top: 22px; align-self: start; overflow: hidden; padding: 30px 27px 24px; border: 1px solid var(--line); border-radius: 4px 18px 4px 4px; background: var(--surface); box-shadow: var(--shadow-lg); backdrop-filter: none; }
.entry-panel::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--accent); }
.eyebrow { margin: 0 0 9px; color: var(--accent); font-size: .61rem; font-weight: 800; letter-spacing: .14em; }
.panel-heading h1, .list-heading h2, .study-heading h2, .empty-state h2 { margin: 0; color: var(--ink); font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif; letter-spacing: -.055em; }
.panel-heading h1 { font-size: clamp(1.7rem, 2.5vw, 2.25rem); line-height: 1.25; }
.panel-heading h1 em { color: var(--accent); font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif; font-style: normal; font-weight: 500; }
.heading-copy { margin: 15px 0 25px; color: var(--muted); font-size: .84rem; line-height: 1.8; }
.card-form { display: grid; gap: 16px; }
.card-form label { display: grid; gap: 7px; }
.card-form label > span { display: flex; gap: 7px; align-items: center; font-size: .75rem; font-weight: 700; }
.card-form b { padding: 2px 5px; border-radius: 2px; color: var(--accent); background: var(--accent-soft); font-size: .58rem; font-weight: 700; }
input, textarea { width: 100%; border: 1px solid #ccc6ba; border-radius: 3px; background: var(--surface-soft); color: var(--ink); transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease; }
input { height: 45px; padding: 0 12px; }
textarea { min-height: 106px; padding: 12px; resize: vertical; line-height: 1.7; }
input::placeholder, textarea::placeholder { color: #aaa39a; }
input:hover, textarea:hover { border-color: #a9a094; background: #fff; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(40, 82, 122, .12); background: #fff; outline: none; }
.form-message { min-height: 1.2em; margin: -4px 0 0; color: var(--accent); font-size: .72rem; line-height: 1.4; }
.form-message.is-error { color: var(--red); }
.form-actions { display: flex; align-items: center; gap: 10px; }
.primary-button, .secondary-button, .shuffle-button, .recall-button, .round-button, .icon-button, .text-button { border: 0; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 45px; flex: 1; padding: 0 16px; border-radius: 3px; color: #fff; background: var(--accent); box-shadow: 0 3px 0 var(--accent-dark); font-size: .82rem; font-weight: 700; transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease; }
.primary-button:hover { background: #32658f; transform: translateY(-1px); }
.primary-button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-dark); }
.button-icon { font-size: 1.05rem; font-weight: 400; line-height: 1; }
.text-button { padding: 7px 0; color: var(--muted); background: transparent; font-size: .71rem; text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover { color: var(--accent); }
.is-hidden { display: none !important; }
.entry-tip { display: flex; gap: 9px; align-items: flex-start; margin-top: 27px; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: .68rem; line-height: 1.65; }
.entry-tip p { margin: 0; }
.tip-icon { color: var(--amber); font-size: .85rem; }
.image-tools, .data-tools { margin-top: 18px; padding-top: 16px; border-top: 1px solid #ebe7df; }
.tools-label { margin: 0 0 8px; color: var(--muted); font-size: .64rem; font-weight: 700; letter-spacing: .07em; }
.image-tool-button { display: inline-flex; width: 100%; min-height: 37px; align-items: center; justify-content: center; gap: 7px; padding: 0 10px; border: 1px solid #b9c7d2; border-radius: 3px; color: var(--accent); background: var(--accent-soft); font-size: .7rem; font-weight: 700; transition: border-color 160ms ease, background 160ms ease; }
.image-tool-button:hover { border-color: var(--accent); background: #e1e9ee; }
.image-tool-button:disabled { cursor: wait; opacity: .62; }
.data-tool-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.data-tool-button { min-height: 35px; padding: 0 7px; border: 1px solid #cfc9bf; border-radius: 3px; color: var(--muted); background: #fff; font-size: .66rem; font-weight: 700; transition: border-color 160ms ease, color 160ms ease, background 160ms ease; }
.data-tool-button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.data-tool-button span { margin-right: 3px; font-size: .82rem; }
.tools-help { margin: 8px 0 0; color: #938e85; font-size: .63rem; line-height: 1.55; }

.main-panel { display: flex; flex-direction: column; gap: 20px; }
.summary-strip { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 96px; padding: 20px 23px; border-bottom: 1px solid var(--line); background: transparent; box-shadow: none; }
.summary-line { margin: 0; color: var(--ink); font-size: clamp(1rem, 1.8vw, 1.16rem); font-weight: 700; letter-spacing: -.025em; }
.summary-stats { display: flex; gap: 22px; flex-shrink: 0; }
.summary-stats div { display: grid; gap: 3px; min-width: 50px; }
.summary-stats div + div { padding-left: 22px; border-left: 1px solid var(--line); }
.summary-stats strong { color: var(--accent); font-family: Georgia, "Times New Roman", serif; font-size: 1.65rem; line-height: 1; }
.summary-stats span { color: var(--muted); font-size: .57rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.mode-switch { display: inline-flex; align-self: flex-start; gap: 0; padding: 0; border-bottom: 1px solid #bcb5a9; border-radius: 0; background: transparent; }
.mode-button { min-height: 39px; padding: 0 15px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; font-size: .77rem; font-weight: 700; transition: color 160ms ease, border-color 160ms ease; }
.mode-button:hover { color: var(--accent); }
.mode-button.is-active { color: var(--ink); background: transparent; border-bottom-color: var(--accent); box-shadow: none; }
.mode-number { margin-right: 4px; color: var(--accent); font-size: .59rem; letter-spacing: .06em; }
.content-view { min-height: 435px; }
.empty-state { display: grid; justify-items: center; align-content: center; min-height: 425px; padding: 45px 28px; border: 1px dashed #c9c1b4; border-radius: 4px 18px 4px 4px; background: rgba(255, 253, 248, .6); text-align: center; }
.empty-state .eyebrow { margin-top: 23px; }
.empty-state h2 { font-size: clamp(1.35rem, 2.4vw, 1.8rem); }
.empty-state > p:not(.eyebrow) { max-width: 360px; margin: 13px 0 23px; color: var(--muted); font-size: .86rem; line-height: 1.8; }
.empty-card-stack { position: relative; width: 68px; height: 53px; }
.empty-card-stack span { position: absolute; width: 54px; height: 40px; border: 1px solid #bcb4a8; border-radius: 2px; background: #fffdf8; box-shadow: 2px 3px 0 rgba(70, 60, 45, .06); }
.empty-card-stack span:nth-child(1) { transform: translate(0, 8px) rotate(-9deg); }
.empty-card-stack span:nth-child(2) { transform: translate(12px, 4px) rotate(7deg); }
.empty-card-stack span:nth-child(3) { transform: translate(7px, 0); border-color: #7891a6; background: var(--accent-soft); }
.secondary-button { padding: 11px 17px; border: 1px solid #b7c4cf; border-radius: 3px; color: var(--accent); background: #fff; font-size: .78rem; font-weight: 700; transition: border-color 160ms ease, background 160ms ease; }
.secondary-button:hover { border-color: var(--accent); background: var(--accent-soft); }

.list-section { animation: fade-up 250ms ease-out both; }
.list-heading, .study-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.list-heading-actions { display: flex; align-items: center; gap: 10px; }
.list-heading h2, .study-heading h2 { font-size: clamp(1.35rem, 2.3vw, 1.8rem); }
.count-pill { padding: 5px 8px; border: 1px solid #cad3da; border-radius: 2px; color: var(--accent); background: transparent; font-family: Georgia, "Times New Roman", serif; font-size: .71rem; font-weight: 700; }
.card-list { overflow: hidden; border: 1px solid var(--line); border-radius: 4px 18px 4px 4px; background: var(--surface); box-shadow: var(--shadow-sm); }
.word-entry { display: grid; grid-template-columns: 43px minmax(0, 1fr) auto; gap: 16px; align-items: center; min-height: 112px; padding: 20px 22px; border-bottom: 1px solid #ece8e0; transition: background 160ms ease; }
.word-entry:last-child { border-bottom: 0; }
.word-entry:hover { background: #fbfaf6; }
.entry-index { align-self: start; padding-top: 3px; color: #9a9287; font-family: Georgia, "Times New Roman", serif; font-size: .95rem; font-weight: 700; }
.word-copy { min-width: 0; }
.word-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.word-copy h3 { margin: 0; overflow-wrap: anywhere; font-family: Georgia, "Times New Roman", serif; font-size: 1.16rem; letter-spacing: -.025em; }
.word-copy p { margin: 7px 0 8px; overflow-wrap: anywhere; color: #524e47; font-size: .83rem; line-height: 1.65; }
.word-copy time { color: #938e85; font-size: .66rem; }
.learned-chip { padding: 3px 7px; border-radius: 2px; font-size: .6rem; font-weight: 700; white-space: nowrap; }
.learned-chip { color: #84602b; background: var(--amber-soft); }
.inferred-chip { padding: 3px 7px; border: 1px solid #c7d5df; border-radius: 2px; color: #49657b; background: #edf3f6; font-size: .6rem; font-weight: 700; white-space: nowrap; }
.entry-actions { display: flex; gap: 5px; align-self: start; }
.icon-button { padding: 7px 8px; border-radius: 2px; color: var(--muted); background: transparent; font-size: .67rem; font-weight: 700; }
.icon-button:hover { color: var(--accent); background: var(--accent-soft); }
.icon-button.is-danger:hover { color: var(--red); background: var(--red-soft); }
.icon-button.is-danger { color: #a24e48; }

.study-section { max-width: 760px; margin: 0 auto; animation: fade-up 250ms ease-out both; }
.study-actions { display: flex; align-items: center; gap: 8px; }
.study-mode-label { color: var(--muted); font-size: .68rem; font-weight: 700; }
.study-mode-select { min-height: 36px; padding: 0 28px 0 10px; border: 1px solid #cfc8bb; border-radius: 3px; color: var(--accent); background: #fffdf8; font-size: .72rem; font-weight: 700; }
.study-mode-select:focus { border-color: var(--accent); outline: 2px solid rgba(40, 82, 122, .12); outline-offset: 1px; }
.empty-study-mode-label { display: block; margin-top: 22px; color: var(--muted); font-size: .68rem; font-weight: 700; }
.empty-study-mode { margin-top: 8px; }
.shuffle-button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 3px; color: var(--accent); background: transparent; font-size: .7rem; font-weight: 700; }
.shuffle-button:hover { background: var(--accent-soft); }
.shuffle-button span { font-size: 1rem; }
.progress-row { display: grid; grid-template-columns: auto minmax(40px, 1fr) auto; align-items: center; gap: 11px; margin: 7px 2px 15px; color: var(--muted); font-size: .67rem; font-weight: 700; }
.progress-track { height: 3px; overflow: hidden; border-radius: 0; background: #d7d1c7; }
.progress-track span { display: block; height: 100%; border-radius: 0; background: var(--accent); transition: width 220ms ease; }
.flashcard { position: relative; display: block; width: 100%; height: 360px; padding: 0; border: 0; background: transparent; perspective: 1100px; text-align: left; }
.flashcard-inner { position: relative; display: block; width: 100%; height: 100%; }
.flashcard.is-flipped .flashcard-inner { transform: none; }
.card-face { position: absolute; inset: 0; display: none; flex-direction: column; align-items: flex-start; justify-content: flex-start; overflow: hidden; padding: 30px 34px 26px; border: 1px solid #cfc8bb; border-radius: 4px 22px 4px 4px; backface-visibility: visible; box-shadow: var(--shadow-lg); }
.card-face::after { content: ""; position: absolute; right: 21px; bottom: 21px; width: 54px; height: 1px; background: #c8c0b2; }
.card-front { display: flex; background: #fffdf8; animation: card-face-in 320ms cubic-bezier(.2,.75,.25,1) both; }
.card-back { border-color: #d9c7a4; background: #fffaf0; }
.flashcard.is-flipped .card-front { display: none; }
.flashcard.is-flipped .card-back { display: flex; animation: card-face-in 320ms cubic-bezier(.2,.75,.25,1) both; }
.face-label { position: relative; z-index: 1; color: var(--accent); font-size: .59rem; font-weight: 800; letter-spacing: .17em; }
.card-back .face-label { color: var(--amber); }
.card-face strong { position: relative; z-index: 1; display: block; width: 100%; max-width: 94%; max-height: 230px; margin: auto 0; overflow: auto; overflow-wrap: anywhere; color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.45rem, 3vw, 2.35rem); font-weight: 600; letter-spacing: -.035em; line-height: 1.5; scrollbar-width: thin; }
.card-back strong { max-height: 242px; font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: clamp(1.1rem, 2.5vw, 1.8rem); font-weight: 600; line-height: 1.75; }
.flip-hint { position: relative; z-index: 1; flex: 0 0 auto; color: var(--muted); font-size: .68rem; }
.flip-hint b { margin-left: 4px; color: var(--accent); }
.study-controls { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 16px; margin: 23px auto 12px; }
.round-button { width: 42px; height: 42px; place-self: center; border: 1px solid #cfc8bb; border-radius: 50%; color: var(--accent); background: #fffdf8; font-size: 1.05rem; box-shadow: 2px 3px 0 rgba(70, 60, 45, .06); transition: background 160ms ease, border-color 160ms ease; }
.round-button:hover { border-color: var(--accent); background: var(--accent-soft); }
.recall-actions { display: flex; justify-content: center; gap: 8px; }
.recall-button { min-width: 116px; padding: 10px 14px; border: 1px solid #cfc8bb; border-radius: 3px; color: var(--muted); background: #fffdf8; font-size: .74rem; font-weight: 700; transition: border-color 160ms ease, background 160ms ease; }
.recall-button:hover { border-color: #9b9387; background: #faf7f0; }
.recall-button.is-mastered { border-color: #d9c28e; color: #80602e; background: var(--amber-soft); }
.recall-button.is-mastered:hover { border-color: var(--amber); background: #f4e7c9; }
.study-footnote { margin: 0; color: #8d877d; font-size: .67rem; text-align: center; }
.study-spark { display: grid; width: 45px; height: 45px; place-items: center; border: 1px solid #d9c7a4; border-radius: 3px; color: var(--amber); background: var(--amber-soft); font-size: 1.2rem; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 5; max-width: min(360px, calc(100vw - 40px)); padding: 13px 17px; border: 1px solid #3b4d5d; border-radius: 3px; color: #fff; background: #273746; box-shadow: 0 8px 18px rgba(20, 32, 51, .16); font-size: .78rem; line-height: 1.5; opacity: 0; pointer-events: none; transform: translateY(13px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--red); border-color: var(--red); }
.dialog-layer { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(55, 49, 41, .38); backdrop-filter: blur(2px); }
.confirm-dialog { width: min(100%, 410px); padding: 27px; border: 1px solid var(--line); border-radius: 4px 18px 4px 4px; background: var(--surface); box-shadow: 0 14px 35px rgba(16, 29, 53, .2); }
.confirm-dialog h2 { margin: 0; font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif; letter-spacing: -.04em; font-size: 1.24rem; }
.confirm-dialog > p:not(.eyebrow) { margin: 13px 0 24px; color: var(--muted); font-size: .8rem; line-height: 1.7; }
.confirm-dialog strong { color: var(--ink); overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.ranking-tab { position: fixed; top: 43%; right: 0; z-index: 4; padding: 11px 7px; border: 1px solid var(--line); border-right: 0; border-radius: 5px 0 0 5px; color: var(--muted); background: var(--surface); box-shadow: var(--shadow-sm); writing-mode: vertical-rl; letter-spacing: .12em; font-size: .67rem; font-weight: 700; }
.ranking-tab:hover { color: var(--accent); background: var(--accent-soft); }
.ranking-dialog { position: relative; width: min(100%, 530px); max-height: min(680px, calc(100vh - 40px)); overflow: auto; padding: 29px; border: 1px solid var(--line); border-radius: 4px 18px 4px 4px; background: var(--surface); box-shadow: 0 14px 35px rgba(16, 29, 53, .2); }
.ranking-dialog h2 { margin: 0; color: var(--ink); font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: 1.45rem; letter-spacing: -.05em; }
.ranking-close { position: absolute; top: 15px; right: 17px; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: transparent; font-size: 1.25rem; line-height: 1; }
.ranking-month { margin: 7px 0 18px; color: var(--muted); font-size: .72rem; }
.ranking-content { display: grid; gap: 8px; }
.ranking-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 3px 10px 3px 3px; background: var(--surface-soft); }
.ranking-rank { color: var(--muted); font-family: "Noto Serif JP", serif; font-size: 1.05rem; text-align: center; }
.ranking-name { overflow: hidden; color: var(--ink); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.ranking-stat { color: var(--muted); font-size: .67rem; white-space: nowrap; }
.ranking-stat b { color: var(--accent); font-size: .8rem; }
.ranking-row.rank-1 { border-color: #c7a64b; background: #fff8de; }
.ranking-row.rank-1 .ranking-rank, .ranking-row.rank-1 .ranking-name { color: #9b761a; }
.ranking-row.rank-2 { border-color: #a9adb0; background: #f1f2f2; }
.ranking-row.rank-2 .ranking-rank, .ranking-row.rank-2 .ranking-name { color: #687077; }
.ranking-row.rank-3 { border-color: #bd8861; background: #faf0e8; }
.ranking-row.rank-3 .ranking-rank, .ranking-row.rank-3 .ranking-name { color: #9a5f3b; }
.ranking-empty, .ranking-loading { margin: 9px 0 4px; color: var(--muted); font-size: .78rem; line-height: 1.7; }
.dialog-cancel, .dialog-delete { min-height: 40px; padding: 0 14px; border-radius: 3px; font-size: .75rem; font-weight: 700; }
.dialog-cancel { border: 1px solid #cfc8bb; color: var(--muted); background: #fffdf8; }
.dialog-cancel:hover { border-color: #9b9387; color: var(--ink); }
.dialog-delete { border: 1px solid var(--red); color: #fff; background: var(--red); box-shadow: 0 2px 0 #79322f; transition: transform 120ms ease, box-shadow 120ms ease; }
.dialog-delete:active { transform: translateY(2px); box-shadow: none; }

@keyframes fade-up { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes card-face-in { from { opacity: 0; transform: translateX(18px) rotateY(-7deg) scale(.985); } to { opacity: 1; transform: translateX(0) rotateY(0) scale(1); } }
@media (max-width: 900px) { .workspace { grid-template-columns: 1fr; gap: 28px; } .entry-panel { position: relative; top: auto; } }
@media (max-width: 560px) {
  .app-shell { padding: 0 15px 32px; }
  .site-header { min-height: 78px; }
  .brand-caption, .header-note { display: none; }
  .workspace { padding-top: 22px; }
  .entry-panel { padding: 27px 20px 21px; }
  .summary-strip { align-items: flex-start; flex-direction: column; gap: 14px; padding: 19px 18px; }
  .summary-stats { width: 100%; gap: 17px; }
  .summary-stats div + div { padding-left: 17px; }
  .mode-switch { width: 100%; }
  .mode-button { flex: 1; padding: 0 7px; }
  .content-view { min-height: 355px; }
  .list-heading, .study-heading { align-items: flex-start; }
  .word-entry { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; min-height: 0; padding: 18px 15px; }
  .entry-actions { grid-column: 2; justify-content: flex-start; align-self: auto; margin-top: 2px; }
  .flashcard { height: 330px; }
  .card-face { padding: 24px 23px 21px; }
  .study-actions { align-items: flex-end; flex-direction: column; gap: 0; }
  .study-controls { grid-template-columns: 40px 1fr 40px; gap: 6px; }
  .round-button { width: 38px; height: 38px; }
  .recall-actions { gap: 5px; }
  .recall-button { min-width: 0; width: 100%; padding: 10px 5px; font-size: .7rem; }
  .toast { right: 16px; bottom: 16px; }
  .confirm-dialog { padding: 24px 20px 21px; }
  .ranking-tab { top: auto; bottom: 92px; padding: 9px 6px; }
  .ranking-dialog { padding: 25px 19px; }
  .ranking-row { grid-template-columns: 27px minmax(0, 1fr); }
  .ranking-stat { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Account and preferences */
.auth-area { display: inline-flex; align-items: center; gap: 8px; margin-left: 8px; }
.auth-loading, .account-name { color: var(--muted); font-size: .68rem; }
.account-button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 3px; color: var(--accent); background: var(--surface); font-size: .68rem; font-weight: 700; }
.account-button:hover { border-color: var(--accent); background: var(--accent-soft); }
.account-button.is-primary { color: #fff; border-color: var(--accent); background: var(--accent); }
.settings-section { animation: fade-up 250ms ease-out both; }
.settings-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.settings-heading h2 { margin: 0; color: var(--ink); font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: clamp(1.45rem, 2.4vw, 1.9rem); letter-spacing: -.05em; }
.settings-note { color: var(--muted); font-size: .7rem; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-card, .guide-section { padding: 22px; border: 1px solid var(--line); border-radius: 4px 14px 4px 4px; background: var(--surface); box-shadow: var(--shadow-sm); }
.settings-card h3, .guide-section h3 { margin: 0 0 16px; color: var(--ink); font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: 1.15rem; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.setting-row > span:first-child { display: grid; gap: 4px; }
.setting-row strong { font-size: .78rem; }
.setting-row small { color: var(--muted); font-size: .67rem; }
.setting-row select { min-height: 34px; padding: 0 24px 0 9px; border: 1px solid var(--line); border-radius: 3px; color: var(--accent); background: var(--surface-soft); font-size: .7rem; }
.setting-toggle { position: relative; cursor: pointer; }
.setting-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle-visual { width: 38px; height: 22px; flex: 0 0 auto; border-radius: 22px; background: #c9c3b9; transition: background 160ms ease; }
.toggle-visual::after { content: ""; display: block; width: 16px; height: 16px; margin: 3px; border-radius: 50%; background: #fff; transition: transform 160ms ease; }
.setting-toggle input:checked + .toggle-visual { background: var(--accent); }
.setting-toggle input:checked + .toggle-visual::after { transform: translateX(16px); }
.account-detail { display: grid; gap: 8px; color: var(--muted); font-size: .74rem; }
.account-detail strong { color: var(--ink); font-size: .9rem; }
.account-detail .account-button { justify-self: start; margin-top: 8px; }
.settings-login-button { min-height: 38px; flex: initial; }
.guide-section { margin-top: 14px; }
.guide-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.guide-heading h3 { margin-bottom: 0; }
.guide-section > p { max-width: 760px; color: var(--muted); font-size: .75rem; line-height: 1.75; }
.csv-header-example, .csv-example { display: block; overflow-x: auto; padding: 12px 14px; border: 1px solid var(--line); border-radius: 3px; color: var(--accent); background: var(--surface-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .69rem; line-height: 1.8; white-space: nowrap; }
.csv-example { margin: 10px 0; color: var(--ink); }
.guide-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: .68rem; }
.howto-list { display: grid; gap: 12px; margin: 0; padding-left: 22px; color: var(--muted); font-size: .75rem; line-height: 1.7; }
.howto-list li { padding-left: 6px; }
.howto-list strong, .howto-list span { display: block; }
.howto-list strong { color: var(--ink); }

:root[data-theme="dark"] { --page: #17212b; --surface: #202d38; --surface-soft: #1b2731; --ink: #e7edf1; --muted: #aebbc4; --line: #3b4a56; --accent: #91b9d3; --accent-dark: #6d98b5; --accent-soft: #263a49; --mint: #8dc8ad; --mint-soft: #244238; --amber: #e0b76d; --amber-soft: #463b27; --red: #ef9c94; --red-soft: #462c2d; --shadow-sm: 0 3px 12px rgba(0, 0, 0, .18); --shadow-lg: 0 10px 25px rgba(0, 0, 0, .3); }
[data-theme="dark"] body { background: var(--page); }
[data-theme="dark"] .paper-texture { opacity: .12; }
[data-theme="dark"] .entry-panel, [data-theme="dark"] .card-list, [data-theme="dark"] .settings-card, [data-theme="dark"] .guide-section, [data-theme="dark"] .empty-state, [data-theme="dark"] .flashcard { background: var(--surface); }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] .study-mode-select, [data-theme="dark"] .setting-row select { color: var(--ink); background: var(--surface-soft); border-color: var(--line); }
[data-theme="dark"] input:hover, [data-theme="dark"] textarea:hover, [data-theme="dark"] input:focus, [data-theme="dark"] textarea:focus { background: #263641; }
[data-theme="dark"] .word-entry:hover { background: #263641; }
[data-theme="dark"] .csv-header-example, [data-theme="dark"] .csv-example { background: var(--surface-soft); }
[data-theme="dark"] .account-button { color: var(--accent); background: var(--surface); }

@media (max-width: 720px) {
  .auth-area { margin-left: 0; }
  .header-note { flex-wrap: wrap; justify-content: flex-end; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-heading, .guide-heading { align-items: flex-start; flex-direction: column; }
  .guide-heading .secondary-button { align-self: stretch; }
}
.admin-table-wrapper { overflow-x: auto; margin-top: 15px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; text-align: left; }
.admin-table th, .admin-table td { padding: 12px 15px; border-bottom: 1px solid var(--line); }
.admin-table th { background: var(--accent-soft); color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.05em; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover { background: var(--surface-soft); }
.admin-auth-card { width: min(100%, 350px); }
.admin-settings-card { display: grid; gap: 10px; }
.admin-setting-row, .admin-check-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink); font-size: .8rem; }
.admin-setting-row input, .admin-setting-row select { width: min(58%, 220px); padding: 8px 9px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); color: var(--ink); }
.admin-check-row { justify-content: flex-start; }
.admin-check-row input { accent-color: var(--accent); }
.admin-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 12px; }
.admin-stat-grid div { border-top: 1px solid var(--line); padding-top: 9px; }
.admin-stat-grid small { display: block; color: var(--muted); font-size: .72rem; }
.admin-stat-grid strong { display: block; margin-top: 2px; color: var(--accent); font-size: 1.45rem; }
.admin-auth-card textarea { width: 100%; }
@media (max-width: 640px) { .admin-stat-grid { gap: 10px; } .admin-table { min-width: 620px; } }
