/* マイページ（LIFF）。スマホ縦持ち前提のモバイルファースト。 */
:root {
  --green: #2e9e5b;
  --green-dark: #237a46;
  --bg: #f5f7f6;
  --card: #ffffff;
  --line: #e0e5e2;
  --text: #1e2a23;
  --muted: #6b7770;
  --danger: #b03030;
  --sub: #c4711f;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.65;
  padding-bottom: env(safe-area-inset-bottom);
}
h1 { font-size: 20px; margin: 4px 0 14px; }
h2 { font-size: 14px; color: var(--muted); margin: 20px 0 7px; font-weight: 600; }
h3 { font-size: 17px; margin: 4px 0 12px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 16px; }

.screen { display: none; }
.screen.active { display: block; }
.view { display: none; padding-bottom: 68px; }
.view.active { display: block; }

.center { min-height: 70vh; display: flex; flex-direction: column;
          align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line);
           border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-icon { width: 40px; height: 40px; line-height: 40px; border-radius: 50%;
              background: #fdeaea; color: var(--danger); font-weight: 700; margin: 0; }

/* ボタン */
.btn { background: var(--green); color: #fff; border: 0; border-radius: 9px;
       padding: 12px 18px; font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer; }
.btn:active { background: var(--green-dark); }
.btn.block { display: block; width: 100%; margin-top: 12px; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn:disabled { background: #c8cfcb; color: #fff; }

/* 生徒コード入力 */
.code-input { width: 100%; padding: 14px; font-size: 24px; letter-spacing: .22em;
              text-align: center; border: 2px solid var(--line); border-radius: 10px;
              text-transform: uppercase; font-family: ui-monospace, Menlo, monospace; }
.code-input:focus { outline: none; border-color: var(--green); }
.link-error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 8px 0 0; }

/* 生徒タブ */
.tabs { display: flex; gap: 6px; padding: 10px 12px 0; overflow-x: auto; background: var(--card);
        border-bottom: 1px solid var(--line); }
.tabs button { flex: 0 0 auto; background: transparent; border: 0; padding: 8px 14px 10px;
               font-size: 15px; font-family: inherit; color: var(--muted);
               border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button.active { color: var(--green); border-bottom-color: var(--green); font-weight: 700; }
.tabs:empty { display: none; }

/* カード */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.card.next { background: linear-gradient(135deg, #2e9e5b, #3fb56d); color: #fff; border: 0; }
.card.next .label { font-size: 13px; opacity: .9; }
.card.next .when { font-size: 22px; font-weight: 700; }
.card.next.none { background: #eef2f0; color: var(--muted); }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0;
       border-bottom: 1px dashed var(--line); }
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); font-size: 14px; flex: 0 0 auto; }
.row .v { text-align: right; word-break: break-all; }
.pw { font-family: ui-monospace, Menlo, monospace; letter-spacing: .05em; }
.pw-toggle { background: #eef2f0; border: 0; border-radius: 6px; padding: 2px 9px;
             font-size: 12px; margin-left: 6px; color: var(--muted); font-family: inherit; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #eaf5ee; color: var(--green-dark); border-radius: 20px;
        padding: 3px 12px; font-size: 13px; }
.chip.empty { background: #f0f2f1; color: var(--muted); }

/* カレンダー */
.cal-header { display: flex; align-items: center; justify-content: center; gap: 18px;
              padding: 14px 0 6px; font-size: 17px; font-weight: 700; background: var(--card);
              border-bottom: 1px solid var(--line); }
.cal-header .nav { background: transparent; border: 0; font-size: 26px; color: var(--green);
                   padding: 0 14px; cursor: pointer; font-family: inherit; }
.cal-legend { display: flex; gap: 14px; justify-content: center; padding: 8px 0;
              font-size: 12px; color: var(--muted); background: var(--card); }
.cal-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
                margin-right: 4px; vertical-align: middle; }
.dot.open { background: #a9c9b5; }
.dot.mine { background: var(--green); }
.dot.sub { background: var(--sub); }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
            background: var(--line); border-top: 1px solid var(--line); }
.calendar .head { background: #eef2f0; text-align: center; font-size: 12px;
                  color: var(--muted); padding: 6px 0; }
.calendar .head.sat { color: #2b6fb0; }
.calendar .head.sun { color: #b03030; }
.cell { background: var(--card); min-height: 58px; padding: 5px 4px; text-align: center;
        font-size: 14px; position: relative; }
.cell.blank { background: #fafbfa; }
.cell.today .day { background: var(--text); color: #fff; border-radius: 50%; }
.cell .day { display: inline-block; width: 24px; height: 24px; line-height: 24px; }
.cell.open { cursor: pointer; }
.cell .mark { display: block; margin: 3px auto 0; width: 8px; height: 8px; border-radius: 50%; }
.cell .mark.open { background: #a9c9b5; }
.cell .mark.sub { background: var(--sub); }
.cell .time { display: block; font-size: 11px; font-weight: 700; color: #fff;
              background: var(--green); border-radius: 4px; margin-top: 2px; padding: 1px 0; }
.cell .time.transferred { background: var(--sub); }

/* 下タブ */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
          border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
.tabbar .tab { flex: 1; background: transparent; border: 0; padding: 13px 0 15px;
               font-size: 14px; color: var(--muted); font-family: inherit; cursor: pointer; }
.tabbar .tab.active { color: var(--green); font-weight: 700; }

/* 詳細シート */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; z-index: 30; }
.sheet.open { display: block; }
.sheet-inner { position: absolute; left: 0; right: 0; bottom: 0; background: var(--card);
               border-radius: 16px 16px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
               max-height: 86vh; overflow-y: auto; }
.sheet-handle { width: 38px; height: 4px; background: var(--line); border-radius: 2px; margin: 6px auto 12px; }
.slot-day { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.slot-day .d { font-weight: 700; margin-bottom: 6px; }
.slot-btns { display: flex; flex-wrap: wrap; gap: 7px; }
.slot { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px;
        font-size: 14px; font-family: inherit; cursor: pointer; }
.slot .c { font-size: 11px; color: var(--muted); display: block; }
.slot:disabled { background: #f2f4f3; color: #aab3ad; cursor: not-allowed; }
.slot.selected { border-color: var(--green); background: #eaf5ee; color: var(--green-dark); font-weight: 700; }
.notice { background: #fdf6e6; border: 1px solid #e8d59a; color: #7a5a10;
          border-radius: 8px; padding: 10px 12px; font-size: 14px; }

/* 通学設定（固定パターン） */
.pattern-row { display: flex; align-items: center; justify-content: space-between;
               gap: 10px; margin-bottom: 8px; }
.pattern-label { font-weight: 700; font-size: 16px; }
.pattern-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 7px; }
.danger-text { color: var(--danger); }
.wd-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.wd-row .wd { flex: 0 0 42px; font-size: 14px; color: var(--muted); }
.wd-row .slot-btns { flex: 1; }
.wd-row .slot { padding: 6px 10px; min-width: 74px; }
#quota-card .row:first-child { padding-top: 0; }
#onboarding { margin-bottom: 14px; }
