:root {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  color: #202e47; background: #f4f6fa; --blue: #345cb3; --line: #dee4ed; --muted: #586a80;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #4676ce; outline-offset: 2px; }
.masthead { background: #fff; border-bottom: 1px solid var(--line); }
.mast-inner, .main { max-width: 1550px; margin: auto; padding-inline: max(2.8vw, env(safe-area-inset-left), env(safe-area-inset-right)); }
.mast-inner, .brand, .tools, .page-heading, .panel-head, .week-controls, .progress-top, footer { display: flex; align-items: center; }
.mast-inner, .page-heading, .panel-head, .progress-top, footer { justify-content: space-between; gap: 12px; }
.mast-inner { min-height: 62px; }
.brand { gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: -.6px; }
.brand img { border-radius: 9px; }
.tools button, #goToday { background: none; border: 0; padding: 8px 12px; color: var(--blue); font-weight: 600; font-size: 14px; min-height: 44px; }
.page-heading { margin: 20px 0; flex-wrap: wrap; }
.date { font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(25px, 2.7vw, 36px); letter-spacing: -.04em; }
h2 { font-size: 21px; letter-spacing: -.035em; }
.week-controls { background: white; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; font-size: 15px; font-weight: 600; }
.week-controls button, .add-btn, .close-btn { border: 0; background: transparent; width: 44px; height: 44px; font-size: 24px; color: var(--blue); }
#goToday { width: auto; border-left: 1px solid var(--line); }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 2.35fr) minmax(250px, 1fr); gap: 16px; align-items: start; }
.panel { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 18px; min-width: 0; }
.panel-head { min-height: 34px; }
.metric, .caption, .progress-top, .period-label, footer, .task-copy small, .event-copy small { color: var(--muted); font-size: 13px; }
.metric b { color: var(--blue); font-size: 17px; }
.caption { margin: 3px 0 12px; }
.day-switch { display: none; }
.timetable { display: grid; grid-template-columns: 28px repeat(5, minmax(0,1fr)); gap: 6px; }
.grid-weekday, .period-label { display: grid; place-items: center; font-weight: 600; }
.grid-weekday { font-size: 14px; min-height: 34px; }
.current { color: var(--blue); background: #eef3ff; border-radius: 8px; }
.lesson-card { border: 1px solid transparent; border-left: 3px solid var(--stripe); border-radius: 8px; background: var(--tint); min-width: 0; height: clamp(58px, 8.1vh, 86px); padding: 6px 9px; text-align: left; display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.lesson-card:hover { filter: brightness(.97); }
.subject-kokugo { --stripe: #6595dc; --tint: #edf3fc; }
.subject-sansu { --stripe: #59a18c; --tint: #e9f5ee; }
.subject-shakai { --stripe: #ce9854; --tint: #fcf2df; }
.subject-taiiku { --stripe: #ca7e90; --tint: #fbecf0; }
.subject-rika { --stripe: #9b84c7; --tint: #f2edfa; }
.subject-other { --stripe: #8999b4; --tint: #eef1f6; }
.subject, .unit, .task-copy strong, .event-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject { font-weight: 700; font-size: 16px; }
.unit { font-size: 13px; color: #4f5e73; }
.empty { background: #fafbfd; color: #65758a; border: 1px dashed #cbd4df; align-items: center; font-size: 14px; }
.side-panels, .list-container, .dialog-fields, .field { display: grid; gap: 12px; min-width: 0; }
.side-panels { gap: 16px; }
.add-btn { border-radius: 50%; background: #f0f4ff; }
.panel-head h2 small { font-size: 14px; color: var(--muted); margin-left: 4px; }
.list-container { margin-top: 12px; gap: 6px; max-height: 31vh; overflow: auto; }
.empty-state { padding: 20px 6px; font-size: 14px; color: var(--muted); text-align: center; border-block-start: 1px solid var(--line); }
.event-row, .task-row { min-width: 0; display: flex; align-items: center; gap: 8px; border: 0; border-top: 1px solid var(--line); background: #fff; text-align: start; padding: 8px 0; }
.event-date { border-radius: 8px; background: #eff3fb; padding: 5px; min-width: 44px; text-align: center; font-size: 13px; color: var(--blue); }
.event-copy, .task-open { flex: 1; min-width: 0; }
.event-copy > *, .task-copy > * { display: block; }
.event-copy small { overflow-wrap: anywhere; }
.task-open { text-align: left; border: 0; background: transparent; min-height: 44px; }
.task-check { width: 22px; height: 22px; accent-color: var(--blue); flex-shrink: 0; }
.task-tag { max-width: 30%; overflow-wrap: anywhere; font-size: 12px; border-radius: 5px; background: #eff3fa; padding: 3px 5px; }
.done strong { text-decoration: line-through; color: var(--muted); }
.progress-top { margin: 12px 0 6px; }
.progress-track { height: 5px; background: #e6ebf3; border-radius: 4px; overflow: hidden; }
#progressBar { height: 100%; background: #688ad0; }
footer { padding-block: 14px max(16px,env(safe-area-inset-bottom)); flex-wrap: wrap; }
.editor-dialog { width: min(94vw,460px); max-height: 88dvh; overflow: auto; border: 1px solid var(--line); border-radius: 18px; padding: 22px; color: inherit; }
.editor-dialog::backdrop { background: #14203966; }
.dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.dialog-fields, .info-content { margin: 14px 0; }
.field { gap: 5px; }
.field label { font-size: 14px; font-weight: 600; }
.field input, .field select { width: 100%; min-width: 0; min-height: 44px; border: 1px solid #c7d0de; background: white; border-radius: 8px; padding: 8px; color: inherit; font-size: 16px; }
.dialog-actions { flex-wrap: wrap; }
.dialog-spacer { flex: 1; }
.primary-btn, .secondary-btn, .danger-btn { min-height: 44px; border: 0; padding: 8px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; }
.primary-btn { color: white; background: var(--blue); }
.secondary-btn { background: #eef1f5; }
.danger-btn { color: #9c3146; background: #fff0f1; }
.info-content p { margin-block: 10px; line-height: 1.6; }
@media(max-width: 700px) {
  .mast-inner, .main { padding-inline: max(12px,env(safe-area-inset-left),env(safe-area-inset-right)); }
  .mast-inner { flex-wrap: wrap; gap: 2px; padding-block: 5px; }
  .brand { font-size: 16px; gap: 6px; }
  .brand img { width: 26px; height: 26px; }
  .tools button { padding-inline: 5px; font-size: 13px; }
  .page-heading { margin: 16px 0 12px; gap: 8px; }
  .week-controls { font-size: 14px; }
  .workspace-grid { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .panel { padding: 13px; border-radius: 14px; }
  .day-switch { display: flex; gap: 4px; margin: 0 0 10px; }
  .day-switch button { min-height: 44px; flex: 1; border: 0; border-radius: 8px; background: #f2f4f8; color: var(--muted); font-weight: 600; }
  .day-switch .active { background: var(--blue); color: #fff; }
  .timetable { grid-template-columns: 30px minmax(0,1fr); gap: 4px; }
  .grid-weekday { display: none; }
  .lesson-card { height: 46px; flex-direction: row; justify-content: flex-start; align-items: center; gap: 12px; }
  .lesson-card.empty { justify-content: center; }
  .side-panels { gap: 12px; }
  .list-container { max-height: 44vh; }
}
.gbar { display:flex; gap:6px; margin-top:8px; }
.gbar button { min-height:44px; padding:0 10px; border:0; border-radius:8px; color:var(--blue); background:#f2f5fb; font-size:14px; }
.gstatus { font-size:13px; line-height:1.55; color:var(--muted); overflow-wrap:anywhere; }
.gstatus:not(:empty) { margin:8px 0; }
.google-event { border-left:4px solid; padding-left:8px; }
#gOptions { max-height:32vh; overflow:auto; margin:10px 0; }
#gOptions label { display:flex; align-items:center; gap:8px; min-height:44px; overflow-wrap:anywhere; }
#gOptions i { width:10px; height:10px; border-radius:50%; flex:none; }

body.locked > :not(#vault) {display:none !important}
#vault form, #backupPass form {display:grid;gap:12px}
#vault [hidden]{display:none}
