@font-face { font-family: "Oswald"; src: url("../assets/fonts/Oswald-ExtraLight.woff2") format("woff2"); font-weight: 200; font-style: normal; font-display: swap; }
@font-face { font-family: "Oswald"; src: url("../assets/fonts/Oswald-Light.woff2") format("woff2"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "Oswald"; src: url("../assets/fonts/Oswald-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Oswald"; src: url("../assets/fonts/Oswald-Medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Oswald"; src: url("../assets/fonts/Oswald-SemiBold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Oswald"; src: url("../assets/fonts/Oswald-Bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  color-scheme: light;
  --accent: #4255ff;
  --accent-hover: #2f43f5;
  --accent-soft: rgba(66, 85, 255, .12);
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --surface-3: #e7e9f2;
  --text: #17171c;
  --muted: #686b7a;
  --border: #d9dce7;
  --green: #138a64;
  --yellow: #9a6500;
  --blue: #4255ff;
  --red: #ff4b44;
  --account-text: #111218;
  --shadow: 0 18px 55px rgba(0, 0, 0, .35);
  --radius: 15px;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151517; --surface: #202023; --surface-2: #29292d; --surface-3: #323237;
  --text: #f5f5f7; --muted: #a8a8b0; --border: #39393f;
  --green: #65d6a6; --yellow: #f5be57; --blue: #7180ff;
  --account-text: #ffffff;
}

* { box-sizing: border-box; }
html { min-width: 300px; min-height: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font-family: "Oswald", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif; line-height: 1.5; overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; }
button, label, select, input[type="checkbox"] { cursor: pointer; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(66, 85, 255, .4); outline-offset: 2px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); flex: 0 0 auto; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
[hidden] { display: none !important; }

.app-header { position: sticky; top: 0; z-index: 50; min-height: 72px; padding: calc(10px + env(safe-area-inset-top)) max(18px, calc((100vw - 1160px) / 2), env(safe-area-inset-right)) 10px max(18px, calc((100vw - 1160px) / 2), env(safe-area-inset-left)); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: color-mix(in srgb, var(--surface) 94%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(15px); }
.brand { justify-self: start; display: inline-flex; align-items: center; gap: 11px; padding: 7px 0; border: 0; background: none; font-size: 1.35rem; font-weight: 700; letter-spacing: .08em; }
.nav-tabs { grid-column: 2; display: flex; justify-content: center; gap: 7px; }
.header-end { justify-self: end; display: flex; align-items: center; gap: 9px; }
.header-icon { flex: 0 0 44px; width: 44px; min-width: 44px; max-width: 44px; padding: 0; background: transparent; }
.nav-button, .button, .icon-button, .rating-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-weight: 720; transition: .16s ease; }
.nav-button { position: relative; padding: 9px 15px; border-color: transparent; background: transparent; color: var(--muted); }
.nav-button:hover, .nav-button[aria-current="true"], .nav-button[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.nav-button[aria-current="true"], .nav-button[aria-current="page"] { box-shadow: inset 0 -2px var(--accent); }
.nav-button.is-active { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 -2px var(--accent); }
.nav-count { min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; background: var(--accent-soft); color: var(--accent-hover); font-size: .72rem; }
.button { padding: 9px 14px; }
.button:hover, .icon-button:hover, .rating-button:hover { border-color: var(--accent); background: var(--surface-2); }
.button.primary, .icon-button.primary-icon { color: #fff; border-color: var(--accent); background: var(--accent); }
.button.primary:hover, .icon-button.primary-icon:hover { background: var(--accent-hover); }
.button.account-button { min-width: 78px; color: #fff; border-color: var(--accent); background: var(--accent); }
.button.account-button:hover { color: #fff; border-color: var(--accent-hover); background: var(--accent-hover); transform: translateY(-1px); }
.button.danger { color: #fff; border-color: var(--red); background: var(--red); }
.icon-button { position: relative; width: 44px; padding: 0; }
.icon-button.danger-icon { color: var(--red); }
.icon-button:disabled, .button:disabled { opacity: .32; cursor: not-allowed; border-color: var(--border); }
.icon-button.is-active { color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
[data-tooltip]::after { content: attr(data-tooltip); position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 100; transform: translate(-50%, 4px); padding: 5px 8px; border-radius: 6px; color: #111; background: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; opacity: 0; pointer-events: none; transition: .14s; }
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

main { width: min(1160px, calc(100% - 32px - env(safe-area-inset-left) - env(safe-area-inset-right))); margin: 32px auto 40px; flex: 1 0 auto; }

.site-footer { flex: 0 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); border-top: 1px solid var(--border); color: var(--muted); background: var(--surface); text-align: center; }
.site-footer p { margin: 0; font-size: .88rem; letter-spacing: .02em; }
.site-footer strong { color: var(--text); font-weight: 700; }
.page-heading { margin-bottom: 22px; }
.page-heading h1 { margin: 0; font-size: clamp(2rem, 5vw, 2.8rem); letter-spacing: -.04em; }
.page-heading p { margin: 7px 0 0; color: var(--muted); }
.centered-heading { text-align: center; }
.deck-reset-button { padding: 4px 14px; border: 0; border-radius: 10px; color: inherit; background: transparent; font-size: inherit; font-weight: inherit; letter-spacing: inherit; }
.deck-reset-button:hover { color: var(--accent); background: var(--accent-soft); }
.panel { padding: clamp(18px, 3vw, 27px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 4px; }
.panel-intro { margin: 0 0 20px; color: var(--muted); }
.grid { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(390px, 1.2fr); gap: 20px; align-items: start; }
.field, .modal-field { display: grid; gap: 7px; margin-bottom: 15px; font-weight: 700; font-size: .9rem; }
input[type="text"], input[type="search"], textarea, select, .modal-input { width: 100%; min-height: 46px; padding: 11px 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
select, select.modal-input { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
textarea { resize: vertical; white-space: pre-wrap; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.status { min-height: 25px; margin-top: 13px; font-size: .9rem; font-weight: 700; }
.status.success { color: var(--green); }
.status.error { color: var(--red); }
.add-success { display: flex; gap: 8px; align-items: center; }
.add-success strong { color: var(--yellow); }
.mode-single { display: flex; align-items: center; gap: 9px; padding: 12px; margin: 10px 0 16px; border: 1px solid var(--accent); border-radius: 10px; color: var(--accent-hover); background: var(--accent-soft); font-weight: 750; }
.privacy-note { display: flex; gap: 10px; margin-top: 20px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; color: var(--muted); background: var(--surface); font-size: .9rem; }

.deck-panel { padding: 18px; }
.deck-topline { display: flex; justify-content: flex-end; margin-bottom: 13px; }
.deck-search-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(160px, 220px); gap: 10px; }
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-wrap input { padding-left: 42px; }
.selection-bar { display: flex; align-items: center; gap: 9px; margin: 13px 0; padding: 11px 12px; border-radius: 11px; background: var(--surface-2); }
.select-all { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.selection-badge { min-width: 29px; height: 27px; padding: 0 9px; display: grid; place-items: center; border-radius: 999px; color: #fff; background: var(--accent); font-size: .82rem; font-weight: 850; }
.toolbar-spacer { flex: 1; }
.root-drop-zone { margin-bottom: 12px; padding: 8px; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); text-align: center; font-size: .78rem; transition: .15s; }
.deck-tree { display: grid; gap: 7px; }
.deck-node { min-width: 0; }
.deck-row { min-width: 0; display: grid; grid-template-columns: 36px 24px minmax(0, 1fr) auto; align-items: center; gap: 7px; min-height: 52px; padding: 5px 8px 5px calc(8px + var(--depth) * 18px); border: 1px solid transparent; border-radius: 10px; background: var(--surface-2); transition: .15s; }
.deck-row:hover { background: var(--surface-3); }
.tree-toggle { width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); }
.tree-toggle .icon { transition: transform .18s ease; }.tree-toggle.is-expanded .icon { transform: rotate(180deg); }
.deck-name { min-width: 0; padding: 8px 4px; overflow: hidden; border: 0; background: transparent; text-align: left; font-weight: 760; text-overflow: ellipsis; white-space: nowrap; }
.tree-actions { display: flex; align-items: center; gap: 5px; }
.tree-action { width: 36px; height: 36px; border-color: transparent; background: transparent; color: var(--muted); }
.tree-action:hover { color: var(--text); }
.deck-count { min-width: 38px; padding: 0 5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.deck-children { margin-left: calc(26px + var(--depth) * 18px); padding: 6px 0 1px 13px; border-left: 1px solid var(--border); display: grid; gap: 6px; }
.tree-card { min-width: 0; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 11px 9px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); transition: .15s; }
.tree-card.without-schedule { grid-template-columns: 24px minmax(0, 1fr) auto; }
.tree-card:hover { border-color: #52525a; }
.tree-card-content { min-width: 0; display: grid; grid-template-columns: minmax(100px, .75fr) minmax(130px, 1.25fr); gap: 16px; align-items: start; }
.tree-card-front { font-weight: 720; overflow-wrap: anywhere; white-space: pre-wrap; }
.tree-card-back { color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; }
.duplicate-card { border-color: var(--red); box-shadow: inset 3px 0 var(--red); }
.duplicate-warning { grid-column: 1 / -1; justify-self: start; padding: 0; border: 0; color: var(--red); background: transparent; font-size: .75rem; font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }
.due-badge { min-width: 57px; padding: 4px 8px; border-radius: 999px; font-size: .75rem; font-weight: 800; text-align: center; white-space: nowrap; }
.due-badge.new { color: var(--blue); background: rgba(114, 167, 255, .13); }
.due-badge.future { color: var(--green); background: rgba(101, 214, 166, .13); }
.due-badge.due { color: var(--yellow); background: rgba(245, 190, 87, .14); }
.due-badge.overdue { color: var(--red); background: rgba(255, 98, 92, .14); }
.root-cards { display: grid; gap: 6px; margin-top: 10px; }
.root-heading { padding: 8px 4px; color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.drop-target { border-color: var(--accent) !important; background: var(--accent-soft) !important; box-shadow: 0 0 0 2px var(--accent-soft); }
.empty-state { padding: 55px 20px; border: 1px dashed var(--border); border-radius: 12px; text-align: center; }
.empty-state .empty-icon { width: 52px; height: 52px; color: var(--accent); }
.empty-state h2 { margin: 8px 0 3px; }
.empty-state p { margin: 0; color: var(--muted); }

.study-shell { width: min(780px, 100%); margin: 0 auto; text-align: center; }
#studyView { min-height: calc(100vh - 125px); }
.study-stats { width: min(360px, 100%); margin: 0 auto 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.study-stats > div { min-height: 50px; padding: 6px 10px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: .8rem; font-weight: 750; }
.study-stats strong { color: var(--text); font-size: 1.25rem; }
.flashcard-scene { position: relative; height: clamp(280px, calc(100vh - 320px), 470px); }
.study-edit-button, .study-undo-button { position: absolute; top: 14px; z-index: 4; width: 44px; height: 44px; background: var(--surface-2); }
.study-edit-button { right: 14px; }
.study-undo-button { left: 14px; }
.flashcard { position: relative; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: pointer; }
.card-face { position: absolute; inset: 0; padding: clamp(20px, 4vw, 38px); display: grid; place-items: center; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); overflow: auto; }
.card-face.back { display: none; grid-template-rows: auto auto; align-content: center; gap: clamp(14px, 3vh, 26px); border-color: var(--accent); }
.flashcard.is-flipped .card-face.front { display: none; }
.flashcard.is-flipped .card-face.back { display: grid; }
.face-text, .back-front-text { max-width: 100%; overflow-wrap: anywhere; white-space: pre-wrap; font-size: clamp(1.55rem, 4.5vw, 3rem); font-weight: 730; line-height: 1.35; }
.back-front-text { align-self: center; font-size: clamp(1.45rem, 4vw, 2.7rem); color: var(--text); font-weight: 730; line-height: 1.25; white-space: pre-wrap; }
.back-text { align-self: center; font-size: clamp(1.45rem, 4vw, 2.7rem); line-height: 1.25; }
.rating-area { min-height: 74px; margin-top: 14px; }
.rating-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.rating-option { min-width: 0; display: grid; grid-template-rows: auto 1fr; gap: 10px; text-align: center; }
.rating-button { width: 100%; min-height: 58px; padding: 8px 10px; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; font-size: 1.12rem; }
.rating-button > span { width: 100%; display: flex; align-items: center; justify-content: center; }
.rating-button > span:last-child { gap: 7px; }
.rating-button .icon { width: 1.12em; height: 1.12em; }
.rating-interval { display: block; color: var(--muted); font-size: 1rem; font-weight: 650; line-height: 1.2; text-align: center; }
.rating-button.again { color: var(--red); }.rating-button.hard { color: var(--yellow); }.rating-button.good { color: var(--blue); }.rating-button.easy { color: var(--green); }
.simple-rating-buttons { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.simple-rating-button { min-height: 70px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); font-size: 1.18rem; font-weight: 700; }
.simple-rating-button .icon { width: 1.18em; height: 1.18em; }
.simple-rating-button.unknown { color: var(--red); }.simple-rating-button.known { color: var(--green); }
.progress-track { display: block; height: 4px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.progress-track > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s ease; }
.study-progress-bottom { width: min(360px, 100%); margin: 0 auto 10px; }
.status-icon { width: 1.25rem; height: 1.25rem; color: var(--yellow); }.completed-icon { color: var(--green); }
.review-preview-card { width: 100%; min-height: 310px; padding: 28px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 14px; color: var(--text); background: var(--bg); cursor: pointer; }
.review-preview-front, .review-preview-back { max-width: 100%; overflow-wrap: anywhere; white-space: pre-wrap; font-size: clamp(1.5rem, 5vw, 2.7rem); font-weight: 600; }
.session-complete { padding: 60px 25px; }
.complete-icon { width: 70px; height: 70px; color: var(--green); }
.session-complete h1 { margin: 10px 0 5px; }.session-complete p { margin: 0 0 22px; color: var(--muted); }

.app-modal { width: min(540px, calc(100% - 28px)); padding: 0; border: 1px solid var(--border); border-radius: 16px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.app-modal::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
.modal-header, .modal-footer { display: flex; align-items: center; gap: 12px; padding: 15px 18px; }
.modal-header { justify-content: space-between; border-bottom: 1px solid var(--border); }.modal-header h2 { margin: 0; font-size: 1.18rem; }
.modal-body { padding: 20px 18px; }.modal-message { margin: 0; color: var(--muted); }
.modal-footer { justify-content: flex-end; border-top: 1px solid var(--border); }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 9px; pointer-events: none; }
.toast { min-width: 250px; max-width: 380px; padding: 12px 15px; border: 1px solid var(--border); border-left: 4px solid var(--blue); border-radius: 10px; background: var(--surface-3); box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }.toast.success { border-left-color: var(--green); }.toast.error { border-left-color: var(--red); }

@media (max-width: 850px) {
  .app-header { grid-template-columns: 1fr; gap: 8px; padding: 9px 14px; }
  .brand { justify-self: center; }.header-end { justify-self: center; grid-row: 1; margin-left: auto; }.nav-tabs { grid-column: 1; width: 100%; }.nav-button { flex: 1; padding-inline: 9px; }
  main { margin-top: 22px; }.grid { grid-template-columns: 1fr; }
  .tree-card { grid-template-columns: 24px minmax(0,1fr) auto; }.tree-card .tree-actions { grid-column: 2 / -1; justify-content: flex-end; }.tree-card-content { grid-template-columns: 1fr; gap: 5px; }
}
@media (max-width: 600px) {
  main { width: min(1160px, calc(100% - 20px - env(safe-area-inset-left) - env(safe-area-inset-right))); margin-bottom: 28px; }
  .brand { justify-self: start; font-size: 1.05rem; }
  .header-end { justify-self: end; gap: 5px; }.account-button { min-width: 0; padding-inline: 9px; font-size: .78rem; }
  .nav-button span:not(.nav-count) { font-size: .76rem; }.nav-button { flex-direction: column; gap: 2px; min-height: 49px; }
  .deck-panel { padding: 11px; }.deck-search-row { grid-template-columns: 1fr; }
  .selection-bar { flex-wrap: wrap; gap: 6px; }.selection-bar .icon-button { width: 40px; height: 40px; min-height: 40px; }.toolbar-spacer { display: none; }.select-all { margin-right: auto; }
  .deck-row { grid-template-columns: 32px 22px minmax(0,1fr); }.deck-row .tree-actions { grid-column: 2 / -1; justify-content: flex-end; }.deck-count { margin-right: auto; }
  .deck-children { margin-left: 12px; padding-left: 8px; }
  .tree-card { gap: 7px; }.due-badge { min-width: 50px; }
  .rating-buttons { grid-template-columns: 1fr 1fr; }.flashcard-scene { height: clamp(220px, calc(100vh - 420px), 340px); min-height: 220px; }
  .rating-button { min-height: 56px; }.rating-area { min-height: 118px; }
  .simple-rating-buttons { grid-template-columns: 1fr 1fr; }.simple-rating-button { min-height: 58px; }
  .toast-region { left: 10px; right: 10px; bottom: 10px; }.toast { min-width: 0; max-width: none; }
}
@media (max-width: 380px) {
  .app-header { padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  .brand { font-size: .95rem; }
  .header-icon { width: 40px; min-width: 40px; height: 40px; }
  .account-button { padding-inline: 7px; font-size: .72rem; }
  .nav-tabs { gap: 2px; }.nav-button { padding-inline: 6px; }
  .panel, .deck-panel { padding: 10px; }
  .selection-bar { padding-inline: 8px; }
  .tree-card-content { min-width: 0; }
  .study-edit-button, .study-undo-button { top: 9px; width: 40px; height: 40px; }
  .study-edit-button { right: 9px; }.study-undo-button { left: 9px; }
}
@media (max-height: 700px) and (min-width: 601px) {
  main { margin-top: 16px; margin-bottom: 20px; }
  .flashcard-scene { height: clamp(220px, calc(100dvh - 330px), 380px); }
  .study-stats > div { min-height: 44px; }
  .rating-area { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
