/* だすMON スタイル（スマホ優先） */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2a44;
  --muted: #667085;
  --line: #e2e6f0;
  --primary: #3b5bdb;
  --primary-dark: #2f49b3;
  --accent: #f59f00;
  --danger: #e03131;
  --ok: #2f9e44;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(31, 42, 68, .08), 0 4px 12px rgba(31, 42, 68, .05);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); line-height: 1.6;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
}
h1, h2, h3 { line-height: 1.3; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
a { color: var(--primary); }
.small { font-size: .85rem; } .muted, .hint, .sub { color: var(--muted); } .hint { font-size: .85rem; margin: .2em 0; }
.loading { text-align: center; color: var(--muted); padding: 3rem 0; }
.mt { margin-top: 1.5rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

/* ---- ボタン・フォーム ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3em; min-height: 44px; padding: .5rem 1rem;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f0f3fa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f1b6b6; }
.btn-link { border: 0; background: none; color: var(--muted); }
.btn-small { min-height: 36px; padding: .25rem .8rem; font-size: .9rem; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: .5rem .7rem; border: 1px solid #c9d0e0; border-radius: 10px; background: #fff; color: var(--ink); font: inherit; font-weight: 400;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible, .cal-cell:focus-visible { outline: 3px solid #b5c4ff; outline-offset: 1px; }
.stack { display: grid; gap: 1rem; }
.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.req { color: var(--danger); font-size: .75rem; margin-left: .3em; }
.radios { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .8rem; display: flex; gap: 1.2rem; flex-wrap: wrap; }
.radios label { display: flex; align-items: center; gap: .4rem; font-weight: 500; }
.radios input { width: auto; min-height: 0; }
.radios .is-disabled { color: var(--muted); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: 20px; min-height: 0; height: 20px; }

/* ---- ログイン画面 ---- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card { width: 100%; max-width: 440px; background: var(--card); border-radius: 20px; padding: 1.6rem 1.4rem; box-shadow: var(--shadow); }
.logo { font-size: 1.6rem; font-weight: 800; color: var(--primary); letter-spacing: .04em; }
.auth-card .logo { text-align: center; margin: 0; }
.auth-legal { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.account-type { padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.account-type-title { display: block; margin-bottom: .4rem; font-size: .92rem; font-weight: 600; }
.account-switch { position: relative; display: inline-flex; align-items: center; gap: .8rem; min-height: 44px; cursor: pointer; }
.account-switch input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; }
.account-switch-track { position: relative; display: block; width: 52px; height: 30px; flex-shrink: 0; border: 1px solid var(--primary); border-radius: 999px; background: var(--primary); }
.account-switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: transform .18s ease; }
.account-switch input:checked ~ .account-switch-track::after { transform: translateX(22px); }
.account-switch-student { color: var(--primary); }
.account-switch-teacher { color: var(--muted); }
.account-switch input:checked ~ .account-switch-student { color: var(--muted); }
.account-switch input:checked ~ .account-switch-teacher { color: var(--primary); }
.account-switch input:focus-visible ~ .account-switch-track { outline: 3px solid #b5c4ff; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .account-switch-track::after { transition: none; } }
.legal-page { max-width: 760px; margin: 0 auto; padding: 2rem 1rem; }
.legal-card { padding: clamp(1.2rem, 4vw, 2rem); }
.legal-card h1 { margin-bottom: .8rem; }
.legal-card h2 { margin-top: 1.5rem; }
.legal-card p, .legal-card li { overflow-wrap: anywhere; }
.legal-links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.5rem; }
.filter-form { display: grid; gap: .8rem; }
.filter-form > label { min-width: 0; }
.filter-form .row { grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
@media (min-width: 600px) {
  .filter-form:not(.stack) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-form:not(.stack) > .task-actions { grid-column: 1 / -1; }
}
.tagline { text-align: center; color: var(--muted); margin: .2rem 0 1.2rem; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; background: var(--bg); padding: .25rem; border-radius: 12px; margin-bottom: 1rem; }
.tab { min-height: 40px; border: 0; border-radius: 9px; background: transparent; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.tab.is-active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.msg { padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem; }
.msg-error { background: #fff0f0; color: #a61e1e; border: 1px solid #f5c2c2; }
.msg-info { background: #edf2ff; color: #2b3f9e; border: 1px solid #c5d0fa; }
.code-input { font-size: 1.8rem; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- アプリ全体のレイアウト ---- */
.app { min-height: 100vh; }
.sidebar { display: none; }
.view { max-width: 820px; margin: 0 auto; padding: 1rem 1rem 6rem; }
.bottomnav {
  position: fixed; inset: auto 0 0 0; display: grid; grid-template-columns: repeat(6, 1fr); background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 10;
}
.nav-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .45rem .1rem; text-decoration: none; color: var(--muted); font-size: .68rem; font-weight: 600; }
.nav-item.is-active { color: var(--primary); }
.nav-icon { font-size: 1.2rem; }
.badge { position: absolute; top: 2px; left: 55%; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .68rem; text-align: center; }
@media (min-width: 860px) {
  .app { display: grid; grid-template-columns: 250px 1fr; }
  .sidebar { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; padding: 1.2rem 1rem; background: #fff; border-right: 1px solid var(--line); }
  .sidebar .nav { display: grid; gap: .2rem; }
  .sidebar .nav-item { flex-direction: row; gap: .6rem; padding: .65rem .8rem; border-radius: 10px; font-size: .95rem; }
  .sidebar .nav-item.is-active { background: #edf2ff; }
  .sidebar .badge { position: static; margin-left: auto; }
  .side-user { margin-top: auto; display: grid; gap: .5rem; }
  .bottomnav { display: none; }
  .view { padding: 1.6rem 1.6rem 3rem; width: 100%; }
}

/* ---- カード・見出し ---- */
.page-head { margin-bottom: 1rem; }
.page-head h1 { margin-bottom: .1rem; }
.card { background: var(--card); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.empty { text-align: center; padding: 2rem 1rem; background: var(--card); border-radius: var(--radius); display: grid; gap: .8rem; justify-items: center; }
.notice { background: #fff8e1; border: 1px solid #ffe08a; padding: .7rem .9rem; border-radius: 10px; }
.back { display: inline-block; margin-bottom: .6rem; text-decoration: none; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .8rem; flex-wrap: wrap; }

/* ---- ホーム ---- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: .9rem; }
.tile { background: var(--card); border-radius: 12px; padding: .6rem .3rem; text-align: center; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 1.5rem; line-height: 1.2; }
.tile span { font-size: .7rem; color: var(--muted); }
.tile-alert b { color: var(--danger); }
.group { margin-top: 1.2rem; }
.group h2 { display: flex; align-items: center; gap: .5rem; }
.group.is-overdue h2 { color: var(--danger); }
.group.is-urgent h2 { color: #d9480f; }
.count { background: var(--line); color: var(--ink); border-radius: 10px; padding: 0 .55rem; font-size: .8rem; }
.task { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem; margin-bottom: .6rem; border-left: 5px solid var(--primary); }
.task.is-urgent { border-left-color: var(--accent); }
.task.is-overdue { border-left-color: var(--danger); }
.task.is-submitted { border-left-color: var(--ok); opacity: .75; }
.task-main { color: inherit; text-decoration: none; display: block; }
.task h3 { margin: 0 0 .2rem; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; margin: 0; font-size: .88rem; color: var(--muted); }
.chip { background: #edf2ff; color: var(--primary); border-radius: 8px; padding: 0 .5rem; font-weight: 700; font-size: .78rem; }
.due { color: var(--ink); }
.is-overdue .due { color: var(--danger); }
.task-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .7rem 0 0; }
.status { border-radius: 8px; padding: 0 .5rem; font-size: .75rem; font-weight: 700; background: #f1f3f5; }
.status-done { background: #fff4d6; color: #8a5a00; }
.status-submitted, .status-approved { background: #e3f6e8; color: #1e7a34; }
.status-pending { background: #fff4d6; color: #8a5a00; }
.status-rejected { background: #ffe3e3; color: #a61e1e; }
.steps { display: flex; gap: .3rem; list-style: none; padding: 0; margin: 1rem 0; font-size: .78rem; }
.steps li { flex: 1; text-align: center; padding: .4rem .2rem; border-radius: 8px; background: var(--bg); color: var(--muted); }
.steps li.is-current { background: var(--primary); color: #fff; font-weight: 700; }
.memo { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }

/* ---- カレンダー ---- */
.cal-head { display: flex; align-items: center; justify-content: center; gap: .8rem; margin-bottom: .6rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-w { text-align: center; font-size: .78rem; color: var(--muted); font-weight: 700; }
.cal-cell { position: relative; aspect-ratio: 1 / 1; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 3px; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; }
.cal-cell.is-empty { border: 0; background: transparent; cursor: default; }
.cal-cell.is-today .cal-day { background: var(--primary); color: #fff; border-radius: 50%; }
.cal-cell.is-selected { border: 2px solid var(--primary); }
.cal-day { min-width: 1.6em; height: 1.6em; text-align: center; font-size: .85rem; line-height: 1.6em; }
.cal-dot { margin-top: auto; align-self: flex-end; min-width: 1.4em; padding: 0 .3em; border-radius: 9px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; }
.cal-dot.is-done { background: var(--ok); }

/* ---- 時間割 ---- */
.table-wrap { overflow-x: auto; }
.tt { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); min-width: 520px; }
.tt th, .tt td { border: 1px solid var(--line); padding: .5rem .4rem; text-align: center; font-size: .85rem; vertical-align: middle; }
.tt th { background: #f8f9fd; }
.tt th b, .tt td b { display: block; }
.tt small { display: block; color: var(--muted); font-size: .7rem; font-weight: 400; }
.tt td { height: 58px; }
.tt .is-today { background: #fff9e6; }
.tt th.is-today { background: #ffe9a8; }

/* ---- お知らせ ---- */
.note { display: flex; gap: .7rem; width: 100%; text-align: left; background: var(--card); border: 0; border-radius: 12px; padding: .8rem 1rem; margin-bottom: .5rem; box-shadow: var(--shadow); font: inherit; color: inherit; cursor: pointer; }
.note-dot { flex: none; width: 10px; height: 10px; margin-top: .5rem; border-radius: 50%; background: transparent; }
.note.is-unread .note-dot { background: var(--danger); }
.note.is-unread { border-left: 4px solid var(--danger); }
.note-body { display: grid; gap: .1rem; }
.note-body span { color: var(--muted); font-size: .9rem; }
.note-body small { color: var(--muted); }

/* ---- アカウント ---- */
.dl { display: grid; grid-template-columns: 9em 1fr; gap: .4rem .8rem; margin: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; overflow-wrap: anywhere; }
.req { }
#req-list .req { display: flex; gap: .6rem; align-items: center; padding: .4rem 0; border-top: 1px solid var(--line); font-size: .9rem; }

/* ---- トースト ---- */
#toasts { position: fixed; left: 50%; bottom: 5.2rem; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 50; width: min(92vw, 420px); }
.toast { padding: .7rem 1rem; border-radius: 10px; background: #1f2a44; color: #fff; box-shadow: var(--shadow); font-size: .92rem; }
.toast-error { background: #a61e1e; } .toast-success { background: #1e7a34; }
@media (min-width: 860px) { #toasts { bottom: 1.5rem; } }

/* ---- 学生：クラスコード入力（ゲート） ---- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--bg); }
.gate-card { width: 100%; max-width: 440px; background: var(--card); border-radius: 20px; padding: 1.6rem 1.4rem; box-shadow: var(--shadow); }
.gate-card .logo { text-align: center; margin: 0; font-size: 1.3rem; }
.gate-text { margin: 0; color: var(--ink); }

/* ---- 新規登録・教官画面の追加パーツ ---- */
.row-2 { grid-template-columns: 1fr 1fr; }
.check-box { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; background: var(--bg); }
.role-tag { font-size: .7rem; background: var(--accent); color: #fff; border-radius: 8px; padding: .1rem .5rem; vertical-align: middle; letter-spacing: 0; }
.radios-col { flex-direction: column; gap: .5rem; }
.chip-gray { background: #f1f3f5; color: var(--muted); }
.class-card h2 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.code-line { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: .3rem 0 .6rem; color: var(--muted); font-weight: 700; }
.code-tag { font-size: 1.5rem; letter-spacing: .2em; color: var(--ink); font-variant-numeric: tabular-nums; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.stu-list { display: grid; gap: .4rem; max-height: 260px; overflow-y: auto; padding: .6rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.pill-row { margin: 0 0 .6rem; }
.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
@media (max-width: 560px) { .hide-sm { display: none; } }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: .5rem .6rem; text-align: left; font-size: .9rem; }
.tbl th { background: #f8f9fd; color: var(--muted); }
.dialog { border: 0; border-radius: 20px; padding: 0; width: min(92vw, 460px); box-shadow: 0 10px 40px rgba(31, 42, 68, .25); color: var(--ink); }
.dialog::backdrop { background: rgba(31, 42, 68, .55); }
.dialog-card { padding: 1.4rem; }
.dialog-card h2 { margin: 0; }
.bottomnav { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
