:root {
  color-scheme: light;
  --ink: #17221e;
  --muted: #66736e;
  --paper: #f4f7f5;
  --card: #ffffff;
  --line: #dce5e0;
  --deep: #122820;
  --green: #1e7757;
  --green-2: #31a575;
  --green-soft: #e2f3eb;
  --yellow: #b37b08;
  --yellow-soft: #fff2c9;
  --red: #b9433d;
  --red-soft: #fbe4e2;
  --shadow: 0 18px 50px rgba(22, 50, 40, .08);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  line-height: 1.6;
}
button, input, select, textarea { font: inherit; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.topbar {
  align-items: center;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 68px;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}
.brand { align-items: center; color: var(--deep); display: flex; font-weight: 800; gap: 10px; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { align-items: center; background: var(--deep); border-radius: 10px; color: #fff; display: inline-flex; font-family: Georgia, serif; font-size: 1.15rem; height: 34px; justify-content: center; width: 34px; }
.brand-mark.large { border-radius: 17px; font-size: 2rem; height: 64px; width: 64px; }
.top-actions { align-items: center; display: flex; gap: 16px; }
.user-name { color: var(--muted); font-size: .875rem; }
.text-button { background: transparent; border: 0; color: var(--green); cursor: pointer; padding: 8px; }

.page-shell { margin: 0 auto; max-width: 1180px; min-height: calc(100vh - 68px); padding: 42px 24px 110px; }
.auth-shell { align-items: center; display: flex; justify-content: center; max-width: none; min-height: 100vh; padding: 24px; background: radial-gradient(circle at 15% 20%, #e1f0e8 0, transparent 32%), radial-gradient(circle at 85% 85%, #d9ece3 0, transparent 26%), var(--paper); }
.page-heading { margin-bottom: 28px; }
.page-heading h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); letter-spacing: -.045em; line-height: 1.15; margin: 4px 0 8px; }
.page-heading p:not(.eyebrow) { color: var(--muted); margin: 0; }
.heading-row { align-items: flex-end; display: flex; gap: 24px; justify-content: space-between; }
.eyebrow { color: var(--green); font-size: .73rem; font-weight: 800; letter-spacing: .15em; margin: 0 0 3px; }
.eyebrow.light { color: #b6ddcc; }
h2 { font-size: 1.35rem; letter-spacing: -.025em; line-height: 1.3; margin: 3px 0 12px; }
h3 { letter-spacing: -.02em; margin: 0; }

.card { background: var(--card); border: 1px solid rgba(208,222,215,.85); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-card { margin-bottom: 24px; padding: 28px; }
.section-heading { align-items: center; display: flex; gap: 20px; justify-content: space-between; }
.section-heading h2 { margin-bottom: 0; }
.section-heading.spaced { margin: 42px 0 18px; }
.button { align-items: center; border: 1px solid transparent; border-radius: 12px; cursor: pointer; display: inline-flex; font-weight: 750; justify-content: center; min-height: 46px; padding: 10px 19px; text-align: center; }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.button.primary { background: var(--deep); color: #fff; }
.button.secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.button.light { background: #fff; color: var(--deep); }
.button.small { min-height: 38px; padding: 6px 14px; }
.button.wide { width: 100%; }
.button-row { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }

.flash { border: 1px solid; border-radius: 12px; margin-bottom: 20px; padding: 13px 16px; }
.flash-success { background: var(--green-soft); border-color: #b8dfcd; color: #155b40; }
.flash-error { background: var(--red-soft); border-color: #efc5c1; color: #8a302b; }
.flash-info { background: #e9eff7; border-color: #cad7e6; color: #36536f; }

.login-card { background: #fff; border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 30px 90px rgba(24,56,44,.13); display: grid; gap: 48px; grid-template-columns: 1.05fr .95fr; max-width: 900px; overflow: hidden; padding: 48px; width: 100%; }
.login-heading { align-self: center; }
.login-heading .eyebrow { margin-top: 24px; }
.login-heading h1 { font-size: clamp(2.5rem, 7vw, 4.5rem); letter-spacing: -.06em; line-height: .95; margin: 8px 0 22px; }
.login-heading > p:last-child { color: var(--muted); max-width: 400px; }
.stack-form { display: flex; flex-direction: column; gap: 19px; }
.login-card form { align-self: center; background: var(--paper); border-radius: 20px; padding: 28px; }
label { color: #34443d; font-size: .9rem; font-weight: 700; }
input, select, textarea { background: #fff; border: 1px solid #cbd8d2; border-radius: 11px; color: var(--ink); margin-top: 6px; min-height: 46px; padding: 10px 12px; width: 100%; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #607069 50%), linear-gradient(135deg, #607069 50%, transparent 50%); background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px); background-repeat: no-repeat; background-size: 6px 6px, 6px 6px; padding-right: 34px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(49,165,117,.15); outline: 0; }
.label-text { display: block; }
label small, .form-note { color: var(--muted); display: block; font-size: .8rem; font-weight: 500; margin-top: 5px; }

.review-hero { align-items: center; background: linear-gradient(120deg, #102a21, #1c5d44); border-radius: 24px; color: white; display: flex; justify-content: space-between; margin: 0 0 22px; min-height: 180px; overflow: hidden; padding: 28px 38px; position: relative; }
.review-hero::after { border: 34px solid rgba(255,255,255,.06); border-radius: 50%; content: ""; height: 190px; position: absolute; right: 18%; top: -87px; width: 190px; }
.review-hero > * { position: relative; z-index: 1; }
.review-hero strong { display: inline-block; font-family: Georgia, serif; font-size: 4.7rem; line-height: 1; margin-right: 12px; }
.review-hero span { color: #d9ece4; }
.review-hero.compact { min-height: 140px; }
.metric-grid { display: grid; gap: 14px; }
.metric-grid.four { grid-template-columns: repeat(4, 1fr); }
.metric-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); display: flex; flex-direction: column; padding: 19px; }
.metric-card:hover { border-color: #9fc7b6; text-decoration: none; }
.metric-card span { color: var(--muted); font-size: .82rem; }
.metric-card strong { font-size: 2rem; line-height: 1.25; }
.metric-card small { color: #8b9892; }

.schedule-chart { align-items: end; display: grid; gap: 10px; grid-template-columns: repeat(8, 1fr); height: 230px; padding: 24px 6px 2px; }
.chart-column { align-items: center; display: flex; flex-direction: column; font-size: .75rem; height: 100%; justify-content: end; }
.chart-value { color: var(--muted); margin-bottom: 4px; }
.chart-track { align-items: end; background: #eef3f0; border-radius: 7px 7px 3px 3px; display: flex; height: 150px; overflow: hidden; width: min(45px, 70%); }
.chart-bar { background: linear-gradient(180deg, #51b88d, #1e7757); border-radius: 7px 7px 3px 3px; height: max(3px, var(--bar-height)); transition: height .4s ease; width: 100%; }
.chart-column:last-child .chart-bar { background: #80ac99; }

.material-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.material-card { padding: 24px; }
.material-title { align-items: flex-start; display: flex; justify-content: space-between; }
.material-title p { color: var(--muted); margin: 2px 0; }
.material-title > strong { color: var(--green); font-family: Georgia, serif; font-size: 2rem; }
.mastery-track, .progress-track { background: #e7eeea; border-radius: 99px; height: 8px; margin: 18px 0; overflow: hidden; }
.mastery-track span, .progress-track span { background: var(--green-2); display: block; height: 100%; width: var(--progress); }
.status-legend { display: grid; font-size: .8rem; gap: 8px 16px; grid-template-columns: repeat(2, 1fr); }
.dot { border-radius: 99px; display: inline-block; height: 8px; margin-right: 7px; width: 8px; }
.dot.remembered { background: var(--green-2); }.dot.unsure { background: #e4b43f; }.dot.forgotten { background: #d65c54; }.dot.unlearned { background: #aab5b0; }
.material-stats { border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); margin: 18px 0; padding: 15px 0; text-align: center; }
.material-stats div + div { border-left: 1px solid var(--line); }
.material-stats span { color: var(--muted); display: block; font-size: .72rem; }
.material-stats strong { font-size: 1.15rem; }
.card-link { display: block; font-weight: 700; text-align: right; }

.form-section { border-bottom: 1px solid var(--line); padding-bottom: 23px; }
.check-grid { display: grid; gap: 11px; grid-template-columns: repeat(4, 1fr); }
.check-card { position: relative; }
.check-card input { height: 1px; opacity: 0; position: absolute; width: 1px; }
.check-card span { background: #f8faf9; border: 2px solid var(--line); border-radius: 14px; display: block; padding: 15px; }
.check-card small { margin: 3px 0 0; }
.check-card input:checked + span { background: var(--green-soft); border-color: var(--green); color: #155b40; }
.check-card.remembered input:checked + span { background: var(--green-soft); border-color: var(--green); }
.check-card.unsure input:checked + span { background: var(--yellow-soft); border-color: var(--yellow); color: #765308; }
.check-card.forgotten input:checked + span { background: var(--red-soft); border-color: var(--red); color: #842f2b; }
.radio-row { display: flex; flex-wrap: wrap; gap: 28px; }
.radio-row label { align-items: center; display: flex; gap: 8px; }
.radio-row input, .inline-checks input { margin: 0; min-height: auto; width: auto; }

.study-shell { margin: 0 auto; max-width: 760px; }
.study-header { align-items: center; display: flex; justify-content: space-between; }
.study-header > a { align-items: center; background: #e5ece8; border-radius: 99px; color: var(--ink); display: flex; font-size: 1.5rem; height: 42px; justify-content: center; width: 42px; }
.study-header > a:hover { text-decoration: none; }
.study-header div { display: flex; flex-direction: column; text-align: right; }
.study-header span { color: var(--muted); font-size: .8rem; }
.progress-track { margin: 14px 0 26px; }
.study-card { align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 25px 70px rgba(24,56,44,.11); color: var(--ink); cursor: pointer; display: flex; flex-direction: column; justify-content: center; min-height: 420px; padding: 45px 24px; position: relative; width: 100%; }
.material-chip { background: #edf3f0; border-radius: 99px; color: #50615a; font-size: .76rem; padding: 5px 11px; position: absolute; top: 23px; }
.pos-label { color: var(--green); font-size: .8rem; font-weight: 750; margin-bottom: 8px; }
.study-term { font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.8rem, 9vw, 5.5rem); font-weight: 600; letter-spacing: -.04em; line-height: 1.05; overflow-wrap: anywhere; }
.tap-hint { bottom: 27px; color: #87958f; font-size: .82rem; position: absolute; }
.translation { border-top: 1px solid var(--line); color: #263832; font-size: clamp(1.3rem, 4vw, 2rem); font-weight: 700; margin-top: 32px; max-width: 560px; padding-top: 26px; width: 85%; }
.rating-panel { margin-top: 22px; text-align: center; }
.rating-panel > p { color: var(--muted); font-size: .85rem; }
.rating-grid { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.rating-grid form { margin: 0; }
.rating { border: 0; border-radius: 15px; cursor: pointer; min-height: 74px; padding: 10px; width: 100%; }
.rating strong, .rating small { display: block; }
.rating small { margin-top: 2px; opacity: .75; }
.rating.forgotten { background: var(--red-soft); color: #8a302b; }.rating.unsure { background: var(--yellow-soft); color: #765308; }.rating.remembered { background: var(--green); color: white; }
.complete-card { margin: 70px auto; max-width: 620px; }
.complete-icon { align-items: center; background: var(--green-soft); border-radius: 99px; color: var(--green); display: flex; font-size: 2rem; height: 74px; justify-content: center; margin: 0 auto 20px; width: 74px; }
.complete-card .button { margin: 6px; }

.tab-row { border-bottom: 1px solid var(--line); display: flex; gap: 24px; margin-bottom: 20px; }
.tab-row a { border-bottom: 3px solid transparent; color: var(--muted); font-weight: 700; padding: 10px 3px; }
.tab-row a.active { border-color: var(--green); color: var(--green); }
.filter-bar { margin-bottom: 14px; max-width: 320px; }
.filter-panel { margin-bottom: 14px; padding: 20px; }
.filter-main { display: grid; gap: 13px; grid-template-columns: 2fr 1fr 1fr; }
.inline-checks { display: flex; flex-wrap: wrap; gap: 12px 20px; margin: 16px 0; }
.inline-checks label { align-items: center; display: flex; font-size: .82rem; gap: 6px; }
.list-study-bar { align-items: center; display: flex; gap: 10px; justify-content: flex-end; margin: 14px 0; }
.list-study-bar select { margin: 0; max-width: 170px; }
.table-card { box-shadow: 0 10px 35px rgba(22,50,40,.06); overflow: hidden; }
.responsive-table { overflow-x: auto; }
table { border-collapse: collapse; min-width: 780px; width: 100%; }
th { background: #f7faf8; color: #65736d; font-size: .72rem; letter-spacing: .04em; text-align: left; }
th, td { border-bottom: 1px solid #e7edea; padding: 13px 15px; vertical-align: middle; }
td { font-size: .85rem; }
td strong { display: block; font-size: 1rem; }
td small { color: var(--muted); display: block; }
tbody tr:last-child td { border-bottom: 0; }
.table-empty { color: var(--muted); padding: 40px; text-align: center; }
.inline-form select { margin: 0; min-height: 36px; padding-bottom: 6px; padding-top: 6px; width: 130px; }
.status-badge { border-radius: 99px; display: inline-block; font-size: .75rem; font-weight: 750; padding: 4px 9px; }
.status-badge.success { background: var(--green-soft); color: #155b40; }.status-badge.warning { background: var(--yellow-soft); color: #765308; }.status-badge.danger { background: var(--red-soft); color: #8a302b; }.status-badge.neutral { background: #e9eeeb; color: #54625c; }
.overdue-text, .missing-text { color: var(--red) !important; }
.pagination { align-items: center; display: flex; gap: 10px; justify-content: flex-end; margin: 18px 0; }
.pagination span { color: var(--muted); font-size: .8rem; margin-right: auto; }
.narrow-form { max-width: 680px; }

.import-guide ul { color: var(--muted); margin-bottom: 0; padding-left: 22px; }
.file-drop { align-items: center; background: #f5f9f7; border: 2px dashed #b9cbc2; border-radius: 16px; display: flex; flex-direction: column; padding: 34px; text-align: center; }
.file-drop input { background: transparent; border: 0; max-width: 340px; }
.mapping-grid { display: grid; gap: 17px; grid-template-columns: repeat(2, 1fr); }
.mapping-grid em { color: var(--red); font-size: .72rem; font-style: normal; }
.table-heading { padding: 22px 24px 10px; }
.settings-grid { display: grid; gap: 20px; grid-template-columns: repeat(2, 1fr); }
.backup-list { border-top: 1px solid var(--line); list-style: none; margin: 20px 0 0; max-height: 260px; overflow: auto; padding: 10px 0 0; }
.backup-list li { align-items: center; display: flex; font-size: .78rem; gap: 12px; justify-content: space-between; padding: 7px 0; }
.empty-state { padding: 48px 28px; text-align: center; }

.bottom-nav { display: none; }

@media (max-width: 780px) {
  .topbar { height: 58px; padding: 0 16px; }
  .brand { font-size: .92rem; }
  .brand-mark { height: 31px; width: 31px; }
  .user-name, .top-actions .text-button { display: none; }
  .page-shell { min-height: calc(100vh - 58px); padding: 26px 14px 98px; }
  .auth-shell { min-height: 100vh; padding: 14px; }
  .heading-row { align-items: flex-start; flex-direction: column; }
  .heading-row > .button, .heading-row > form, .heading-row > form .button { width: 100%; }
  .login-card { gap: 28px; grid-template-columns: 1fr; padding: 26px 20px; }
  .login-heading h1 { font-size: 3.3rem; }
  .login-card form { padding: 20px; }
  .review-hero { align-items: flex-start; flex-direction: column; gap: 22px; padding: 26px; }
  .review-hero strong { font-size: 4rem; }
  .review-hero form, .review-hero .button { width: 100%; }
  .metric-grid.four { grid-template-columns: repeat(2, 1fr); }
  .metric-card { padding: 15px; }
  .metric-card strong { font-size: 1.7rem; }
  .section-card { padding: 20px; }
  .schedule-chart { gap: 5px; height: 190px; margin: 0 -8px; }
  .chart-track { height: 115px; width: 65%; }
  .chart-column { font-size: .65rem; }
  .material-grid, .settings-grid { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: repeat(2, 1fr); }
  .study-shell { margin-top: -8px; }
  .study-card { min-height: 52vh; padding: 40px 18px; }
  .study-term { font-size: clamp(2.5rem, 14vw, 4.5rem); }
  .rating-grid { gap: 7px; }
  .rating { min-height: 70px; padding: 8px 3px; }
  .rating strong { font-size: .92rem; }
  .rating small { font-size: .68rem; }
  .filter-main { grid-template-columns: 1fr; }
  .list-study-bar { align-items: stretch; flex-direction: column; }
  .list-study-bar select { max-width: none; }
  .mapping-grid { grid-template-columns: 1fr; }
  .button-row { width: 100%; }
  .button-row .button { flex: 1; }
  .bottom-nav { background: rgba(255,255,255,.96); border-top: 1px solid var(--line); bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); left: 0; padding: 6px max(4px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left)); position: fixed; right: 0; z-index: 30; }
  .bottom-nav a { align-items: center; color: #77847e; display: flex; flex-direction: column; font-size: .65rem; font-weight: 700; gap: 1px; padding: 2px; }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a span { font-size: 1.1rem; line-height: 1.35; }
  .bottom-nav a.active { color: var(--green); }
}

@media (max-width: 390px) {
  .metric-grid.four { grid-template-columns: 1fr 1fr; gap: 9px; }
  .check-grid { grid-template-columns: 1fr; }
  .status-legend { grid-template-columns: 1fr; }
}

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

