:root {
  --paper: #efece4;
  --light: #f9f7f1;
  --ink: #171816;
  --muted: #68685f;
  --line: #c7c4ba;
  --red: #c84231;
  --red-dark: #9f2c20;
  --panel: #e7e5dc;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: "Noto Sans JP", sans-serif;
  background-color: var(--paper);
  background-image: linear-gradient(#17181609 1px, transparent 1px), linear-gradient(90deg, #17181609 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.frame {
  position: relative;
  width: 100%;
  max-width: 920px;
  min-height: 580px;
  background: var(--light);
  border: 1px solid var(--ink);
  box-shadow: 0 12px 40px #1718161f;
  overflow: hidden;
}
.spine { position: absolute; inset: 0 auto 0 0; width: 7px; background: var(--red); }
.kicker, .mono-label, .tile-num, .view-note, .badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.kicker { color: var(--red-dark); margin-bottom: 24px; }
h1 { font-size: clamp(36px, 6vw, 68px); letter-spacing: -.055em; line-height: 1.04; margin-bottom: 12px; }
.jp-line { color: var(--red); font-size: 24px; margin-bottom: 24px; }
.note { color: var(--muted); font-size: 15px; line-height: 1.75; max-width: 65ch; }
.gate-grid { display: grid; grid-template-columns: 1.05fr 1fr; }
.editorial { position: relative; padding: 56px 48px 100px 56px; }
.hanko, .hanko-sm {
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--red); color: var(--red); font-weight: 700; transform: rotate(-3deg);
}
.hanko { position: absolute; right: 40px; bottom: 40px; width: 64px; height: 64px; font-size: 30px; }
.hanko-sm { width: 36px; height: 36px; font-size: 18px; flex: none; }
.form-panel { background: var(--panel); padding: 56px 48px; border-left: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
.form-panel h2 { font-size: 22px; margin-bottom: 8px; }
.helper { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 32px; }
.pw-row { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.pw-row input { min-width: 0; background: transparent; border: 0; border-bottom: 2px solid var(--ink); margin: 0; }
#showBtn { border: 0; padding: 4px 0; background: transparent; font: 11px "IBM Plex Mono", monospace; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; padding: .6rem .8rem; border: 1px solid var(--line); background: var(--paper); color: var(--ink); }
button:hover { border-color: var(--ink); }
button:disabled { cursor: default; opacity: .6; }
button.continue { padding: 14px; background: var(--ink); color: white; font-weight: 700; }
button.continue:hover { background: var(--red-dark); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
a { color: var(--red-dark); }
.err { color: var(--red-dark); font-size: 13px; margin-top: 12px; min-height: 20px; }
.app-inner { padding: 36px 48px 48px 56px; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.pill-toggle { display: flex; flex-shrink: 0; background: #dedcd3; border-radius: 999px; padding: 4px; min-width: 220px; }
.pill-toggle button { flex: 1; border: 0; background: transparent; color: #494a43; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.pill-toggle button.active { background: var(--ink); color: white; }
.view-note { color: var(--muted); margin: 16px 0; }
nav.modules { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 32px; font-size: 13px; font-weight: 700; }
nav.modules a { padding: 12px 10px; color: var(--muted); white-space: nowrap; text-decoration: none; border-bottom: 2px solid transparent; }
nav.modules a[aria-current] { color: var(--ink); border-bottom-color: var(--red); }
.mod-title { font-size: clamp(28px, 4vw, 44px); letter-spacing: -.04em; line-height: 1.1; margin-bottom: 16px; }
.freshness { color: var(--muted); font-size: .8rem; margin: .8rem 0; }
.notice { padding: .8rem 1rem; margin: 1rem 0; background: var(--paper); border-left: 3px solid var(--red); line-height: 1.6; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 28px; }
.tile { border: 1px solid var(--line); background: var(--paper); padding: 20px; }
.tile-num { color: var(--red-dark); margin-bottom: 12px; }
.tile b { display: block; font-size: 15px; margin-bottom: 8px; }
.tile span { color: var(--muted); font-size: 13px; line-height: 1.6; }
.home-tiles h3 { margin: 0 0 12px; font-size: 21px; line-height: 1.4; }
.home-tiles .tile > p:not(.tile-num) { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 16px; }
.home-tiles button, .home-tiles a { font-size: 13px; }
.trip-tile { position: relative; }
.trip-tile .tile-num { padding-right: 24px; }
.home-tiles .trip-menu { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; padding: 0; border: 0; background: transparent; font-size: 26px; font-weight: 700; line-height: 1; letter-spacing: 1px; color: var(--muted); }
.trip-menu:hover { color: var(--ink); }
dialog { margin: auto; width: min(480px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 28px; border: 1px solid var(--ink); background: var(--light); color: var(--ink); }
dialog::backdrop { background: #17181666; }
dialog h2 { font-size: 22px; margin-bottom: 24px; }
.edit-actions { display: flex; gap: 8px; margin-top: 16px; }
.home-copy { white-space: pre-wrap; overflow-wrap: anywhere; }
.tracked-summary { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 28px; color: var(--muted); font-size: 13px; line-height: 1.7; }
label { display: block; font-size: .85rem; }
input, select, textarea { display: block; width: 100%; padding: .6rem; background: var(--light); color: var(--ink); border: 1px solid var(--line); margin: .3rem 0 .8rem; }
textarea { resize: vertical; min-height: 4rem; }
.lib-controls { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 4px; }
.lib-controls label { flex: 1 1 150px; }
.lib-meta { color: var(--muted); font-size: 13px; margin: 8px 0; }
.lib-list { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.lib-row { border-top: 1px solid var(--line); padding: 12px 2px; }
.lib-row summary { cursor: pointer; white-space: pre-wrap; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
dl { margin: 1rem 0; }
dt { color: var(--muted); font-size: .8rem; margin-top: .6rem; }
dd { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.lib-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge { font-size: 10px; border: 1px solid var(--line); color: var(--muted); padding: 3px 8px; }
.editor { margin: 1.2rem 0; padding: 1rem; border: 1px solid var(--line); background: var(--paper); }
.editor summary { cursor: pointer; overflow-wrap: anywhere; }
.editor h3 { display: inline; }
.editor form, .editor label { margin-top: .8rem; }
.lesson-picker { margin-top: 1.5rem; }
h3 { margin: 1rem 0 .5rem; }
@media (max-width: 760px) {
  body { padding: 20px 12px; align-items: flex-start; }
  .frame { min-height: 0; }
  .gate-grid { grid-template-columns: 1fr; }
  .editorial { padding: 40px 32px 88px 40px; }
  .hanko { right: 24px; bottom: 24px; width: 52px; height: 52px; font-size: 24px; }
  .form-panel { border-left: 0; border-top: 1px solid var(--line); padding: 40px 32px; }
  .app-inner { padding: 28px 24px 36px 32px; }
  .app-header { flex-wrap: wrap; justify-content: flex-start; }
  .brand { width: 100%; }
  nav.modules { gap: 0; }
  nav.modules a { padding: 12px 6px; }
  .tiles { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; }
}
