:root {
  --paper: #eef1ec;
  --sheet: #fbfcfa;
  --ink: #1e2a23;
  --ink-soft: #5d6b62;
  --line: #d5dcd3;
  --leaf: #3f6b4c;
  --orchid: #8b3a6b;
  --orchid-wash: #f3e6ee;
  --mute: #a2aca5;
  --focus: #8b3a6b;
  --radius-sheet: 14px;
  --radius-ctl: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #18201b;
    --sheet: #202a24;
    --ink: #e6ece7;
    --ink-soft: #a4b2a8;
    --line: #34413a;
    --leaf: #8fbf9c;
    --orchid: #e39ac6;
    --orchid-wash: #3a2733;
    --mute: #6c7a71;
    --focus: #e39ac6;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "BIZ UDPGothic", "Hiragino Sans", sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

/* 日付と教室 */
.date {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 0.35em;
  margin: 4px 0 14px;
  font-family: "Shippori Mincho B1", serif;
  font-weight: 600;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: 0.02em;
}
.date .dow { font-size: 0.55em; color: var(--ink-soft); }
.date input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

.rooms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}
.rooms button {
  flex: 1 0 auto;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--sheet);
  white-space: nowrap;
  cursor: pointer;
}
.rooms button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  font-weight: 700;
}

/* 取り込み */
.import {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 1.5px dashed var(--leaf);
  border-radius: var(--radius-ctl);
  color: var(--leaf);
  font-weight: 700;
  cursor: pointer;
}
.import input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.import:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

.preview {
  margin-top: 10px;
  padding: 14px;
  border-radius: var(--radius-ctl);
  background: var(--sheet);
  border: 1px solid var(--line);
  display: grid;
  gap: 10px;
}
.preview .course-name { font-weight: 700; }
.preview .error { color: var(--orchid); }
.btn {
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-ctl);
  border: 1px solid var(--line);
  background: var(--sheet);
  cursor: pointer;
}
.btn.primary {
  background: var(--leaf);
  border-color: var(--leaf);
  color: var(--sheet);
  font-weight: 700;
}
.btn:disabled { opacity: 0.4; cursor: default; }

/* 表 */
.sheet {
  margin-top: 18px;
  background: var(--sheet);
  border-radius: var(--radius-sheet);
  border: 1px solid var(--line);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
col.c-att { width: 48px; }
col.c-amt { width: 84px; }
thead th {
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-soft);
  text-align: right;
  padding: 10px 10px 6px;
  white-space: nowrap;
}
thead th.t-name { text-align: left; padding-left: 14px; }
thead th.t-att { text-align: center; padding: 10px 0 6px; }

tbody th.course {
  text-align: left;
  padding: 16px 14px 6px;
  font-size: 15px;
  color: var(--leaf);
  border-top: 1px solid var(--line);
}
tbody th.course select { width: 100%; }

td {
  border-top: 1px solid var(--line);
  padding: 0;
  height: 52px;
  vertical-align: middle;
}
td.name {
  padding: 0 6px 0 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
td.name select {
  display: block;
  width: 100%;
  margin-top: 2px;
  font-size: 14px;
  min-height: 34px;
}
tr.absent td.name { color: var(--mute); }
td.name input.who {
  width: 100%;
  height: 40px;
  border: 0;
  border-bottom: 1px dashed var(--line);
  padding: 0;
  background: transparent;
}
td.name input.who:focus { outline: none; border-bottom: 2px solid var(--orchid); }

td.att { text-align: center; }
.mark {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  line-height: 44px;
  color: var(--orchid);
}
.mark.on { background: var(--orchid-wash); }
.mark.raw { font-size: 13px; color: var(--orchid); }
.mark:not(.on) { color: var(--mute); box-shadow: inset 0 0 0 1.5px var(--line); }
.mark.raw.on { color: var(--orchid); }

td.amt input {
  display: block;
  width: 100%;
  height: 52px;
  border: 0;
  padding: 0 10px 0 4px;
  background: transparent;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 17px;
}
td.amt input:focus { background: var(--orchid-wash); outline: none; box-shadow: inset 0 -3px 0 var(--orchid); }

tfoot td {
  border-top: 3px double var(--ink);
  height: 60px;
  text-align: right;
  padding: 0 10px 0 4px;
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.save {
  display: block;
  width: 100%;
  margin-top: 18px;
}

.error { color: var(--orchid); }
.save-error { margin-top: 10px; }

/* ログイン */
.login { max-width: 420px; padding-top: max(56px, env(safe-area-inset-top)); }
.login-title {
  margin: 0 0 28px;
  font-family: "Shippori Mincho B1", serif;
  font-weight: 600;
  font-size: 40px;
  letter-spacing: 0.04em;
}
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 6px; font-size: 14px; color: var(--ink-soft); }
.login-form input {
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  background: var(--sheet);
  font-size: 17px;
  color: var(--ink);
}
.login-form input:focus { outline: none; border-color: var(--orchid); box-shadow: 0 0 0 3px var(--orchid-wash); }
.login-form .btn { margin-top: 8px; }

@media (max-width: 400px) {
  .rooms { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .rooms button { padding: 0 2px; font-size: 13px; letter-spacing: -0.02em; }
  thead th { font-size: 12px; padding-right: 8px; padding-left: 0; }
  col.c-att { width: 44px; }
  col.c-amt { width: 72px; }
  td.name { padding-left: 12px; }
  td.amt input { padding-right: 8px; }
  tfoot td { font-size: 15px; padding-right: 8px; }
  tfoot td + td { padding-left: 0; }
}

@media (min-width: 700px) {
  col.c-amt { width: 120px; }
  .date { font-size: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---- タブと画面(全体の地図の絵と同じ形) ---- */
body.tabs #app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
body.tabs #app > .wrap { flex: 1; width: 100%; }
.tabbar { position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--sheet); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabbar button { height: 60px; border: 0; background: transparent; font-size: 15px; color: var(--ink-soft); cursor: pointer; }
.tabbar button[aria-current="page"] { color: var(--ink); font-weight: 700; box-shadow: inset 0 3px 0 var(--orchid); }
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 4px 0 14px; }
.head h1 { margin: 0; font-family: "Shippori Mincho B1", serif; font-weight: 600; font-size: 30px; white-space: nowrap; line-height: 1.15; }
.head .dow { font-size: .55em; color: var(--ink-soft); margin-left: .35em; }
.head .nav { display: flex; gap: 4px; }
.head .nav button { width: 44px; height: 44px; border: 0; background: transparent; font-size: 22px; color: var(--ink-soft); cursor: pointer; }
.room-name { font-size: 20px; color: var(--ink-soft); white-space: nowrap; }
.sec { margin: 26px 0 0; font-size: 15px; color: var(--leaf); font-weight: 700; }
.list { margin-top: 12px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-sheet); overflow: hidden; }
.list .row { display: grid; grid-template-columns: 1fr 80px 80px; column-gap: 10px; align-items: center; min-height: 54px; padding: 0 12px 0 14px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.list .row:first-child { border-top: 0; }
.list .row .n { text-align: right; white-space: nowrap; }
.list .row .d { line-height: 1.35; padding: 6px 0; min-width: 0; word-break: keep-all; overflow-wrap: anywhere; line-break: strict; }
.list .row .d small { display: block; color: var(--ink-soft); font-size: 13px; }
.list .hd { min-height: 34px; font-size: 12px; color: var(--ink-soft); }
.list .tot { border-top: 3px double var(--ink); font-weight: 700; }
.list .strong { font-weight: 700; }
.list.two .row { grid-template-columns: 1fr auto; }
.list.grid4 .row { grid-template-columns: 1fr 70px 70px 70px; }
.list.grid5 .row { grid-template-columns: 1fr 54px 54px 58px 54px; }
.list .row.tap { cursor: pointer; }
.list input.num { width: 100%; height: 40px; border: 0; border-bottom: 1px dashed var(--line); background: transparent; text-align: right; font-variant-numeric: tabular-nums; padding: 0 2px; }
.list input.num:focus { outline: none; background: var(--orchid-wash); border-bottom: 2px solid var(--orchid); }
.list.two input.num { width: 96px; }
.list.prices.grid5 input.num { font-size: 15px; padding: 0; }
.stepper { justify-self: end; display: flex; gap: 10px; align-items: center; font-variant-numeric: tabular-nums; }
.stepper button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; }
.stepper span { min-width: 1.2em; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-sheet); padding: 12px 8px; }
.cal button, .cal span { display: flex; align-items: center; justify-content: center; height: 46px; border: 0; border-radius: 10px; background: transparent; font-variant-numeric: tabular-nums; cursor: pointer; }
.cal span.w { height: 28px; font-size: 13px; color: var(--ink-soft); cursor: default; }
.cal button.done { background: var(--ink); color: var(--paper); font-weight: 700; }
.cal button.today { box-shadow: inset 0 0 0 1.5px var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: 14px; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.ring { justify-self: end; width: 36px; height: 36px; border: 1.5px solid var(--line); border-radius: 50%; background: transparent; color: var(--orchid); font-size: 20px; cursor: pointer; }
.ring[aria-pressed="true"] { background: var(--orchid-wash); border-color: var(--orchid-wash); }
.chk { justify-self: end; width: 28px; height: 28px; accent-color: var(--orchid); }
.pick { display: flex; align-items: center; justify-content: center; min-height: 52px; border: 1.5px dashed var(--leaf); border-radius: var(--radius-ctl); color: var(--leaf); font-weight: 700; background: transparent; width: 100%; cursor: pointer; }
.form { display: grid; gap: 10px; margin-top: 12px; padding: 14px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-sheet); }
.form input, .form select { min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-ctl); background: var(--paper); }
.dpick { position: relative; display: block; height: 40px; border-bottom: 1px dashed var(--line); text-align: right; line-height: 40px; font-size: 14px; font-variant-numeric: tabular-nums; }
.dpick input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.list .row .d small.one { white-space: nowrap; font-size: 12px; }
tr.late td.amt input { color: var(--orchid); }
.rooms.sm { margin: 0 0 14px; }
@media (max-width: 400px) {
  .list .row { grid-template-columns: 1fr 74px 74px; padding-right: 8px; }
  .list.grid4 .row { grid-template-columns: 1fr 62px 62px 62px; column-gap: 8px; }
  .list.grid4 .n, .list.grid4 input.num { font-size: 15px; }
  .list.grid5 .row { grid-template-columns: 1fr 46px 46px 58px 46px; column-gap: 9px; }
  .list.grid5 .n, .list.grid5 input.num { font-size: 14px; }
  .list .hd .n { font-size: 12px; }
  .list.prices:not(.grid5) .row { grid-template-columns: 1fr 70px 70px; column-gap: 8px; }
  .list.prices input.num { font-size: 15px; padding: 0; }
  .list.prices .d { font-size: 15px; }
  .list.prices.grid5 .row { grid-template-columns: 1fr 50px 46px 50px 46px; column-gap: 6px; }
  .list.prices.grid5 input.num { font-size: 14px; }
}
