/* KOBO portal. Same tokens and components as KIRITORI (kiritori/web/assets/app.css), plus dark mode. */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #17171a;
  --ink-2: #3c3c42;
  --muted: #76767e;
  --line: #e3e1db;
  --line-strong: #cfccc4;
  --accent: #1d2f4f;
  --accent-ink: #ffffff;
  --accent-soft: #e8ecf3;
  --ok: #2f6b4f;
  --ok-soft: #e4efe8;
  --warn: #8a5a12;
  --warn-soft: #f6eddc;
  --bad: #a23b32;
  --bad-soft: #f6e4e1;
  --on-ink: #ffffff;          /* text on an --ink background (primary buttons, toast) */
  --ink-hover: #000000;
  --topbar-bg: rgba(245, 244, 240, .88);
  --focus: rgba(23, 23, 26, .08);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .04), 0 4px 16px rgba(20, 20, 30, .05);
  --font: "Inter", "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  --serif: "Hiragino Mincho ProN", "Noto Serif JP", serif;
  --topbar-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --surface: #1b1b1f;
    --surface-2: #222227;
    --ink: #ececef;
    --ink-2: #c8c8ce;
    --muted: #96969e;
    --line: #2c2c33;
    --line-strong: #41414a;
    --accent: #a9bde0;
    --accent-ink: #121214;
    --accent-soft: #1f2a3d;
    --ok: #7fc8a3;
    --ok-soft: #17291f;
    --warn: #e2b46a;
    --warn-soft: #2f2514;
    --bad: #f0897f;
    --bad-soft: #351a1a;
    --on-ink: #121214;
    --ink-hover: #ffffff;
    --topbar-bg: rgba(18, 18, 20, .86);
    --focus: rgba(236, 236, 239, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 28px;
  padding: 0 max(20px, env(safe-area-inset-left));
  background: var(--topbar-bg);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; letter-spacing: .18em; font-size: 14px; text-decoration: none; white-space: nowrap; }
.topnav { display: flex; gap: 20px; flex: 1; min-width: 0; }
.topnav a { text-decoration: none; color: var(--muted); font-size: 14px; padding: 4px 0; border-bottom: 1.5px solid transparent; white-space: nowrap; }
.topnav a:hover { color: var(--ink); }
.topnav a.active { color: var(--ink); border-bottom-color: var(--ink); }
.topright { display: flex; align-items: center; gap: 10px; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 6px 0; text-decoration: none; white-space: nowrap; }
.linkbtn:hover { color: var(--ink); }

.app { width: 100%; max-width: 1120px; margin: 0 auto; padding: 36px 20px 80px; flex: 1; }
.app.narrow { max-width: 760px; }
.loading { color: var(--muted); padding: 60px 0; text-align: center; }

/* ---------- typography ---------- */
h1 { font-size: 24px; font-weight: 600; letter-spacing: .01em; margin: 0; line-height: 1.35; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 14px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.eyebrow { font-size: 12px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; font-family: "Inter", var(--font); }
.lead { color: var(--muted); margin: 8px 0 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover { background: var(--ink-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
.btn.block { width: 100%; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 24px; }
.card + .card, .stack > * + * { margin-top: 16px; }
.empty { text-align: center; padding: 72px 20px; color: var(--muted); }
.empty p { margin: 0 0 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

.badge {
  display: inline-block; font-size: 12px; line-height: 1; padding: 6px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.run { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.banner { display: flex; gap: 12px 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 14px 18px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.banner .btn { flex: none; }

/* ---------- forms ---------- */
.section { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 28px 0; border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; padding-top: 0; }
.section:last-child { padding-bottom: 0; }
.section-label h2 { margin-bottom: 4px; }
.section-label p { margin: 0; color: var(--muted); font-size: 13px; }
.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.hint { font-size: 12px; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); padding: 10px 12px; font-size: 15px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--focus); }
.input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; margin-bottom: 0; }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 14px; flex-wrap: wrap; }
.error { color: var(--bad); font-size: 13px; min-height: 20px; }
.msg { font-size: 13px; min-height: 20px; }
.msg.ok { color: var(--ok); }
.msg.bad { color: var(--bad); }
.copyrow { display: flex; gap: 8px; }
.copyrow .input { flex: 1; min-width: 0; font-size: 13px; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented button {
  border: 0; background: transparent; padding: 8px 18px; border-radius: 999px; cursor: pointer;
  font-size: 14px; color: var(--muted); font-weight: 500;
}
.segmented button.on { background: var(--ink); color: var(--on-ink); }
.segmented .save { font-size: 11px; margin-left: 6px; opacity: .8; }

/* ---------- auth pages ---------- */
.login-wrap { min-height: calc(100vh - 260px); display: grid; place-items: center; }
.login { width: 100%; max-width: 380px; }
.login .brand-lg { font-weight: 600; letter-spacing: .24em; font-size: 15px; margin-bottom: 36px; text-align: center; }
.login h1 { font-size: 22px; margin-bottom: 6px; }
.login p.lead { color: var(--muted); margin: 0 0 28px; font-size: 14px; }
.login .alt { margin-top: 22px; font-size: 13px; color: var(--muted); display: grid; gap: 6px; text-align: center; }
.login .alt a { color: var(--ink); }
.login .btn + .btn { margin-top: 10px; }
.notice { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; margin-bottom: 20px; }

/* ---------- landing ---------- */
.hero { padding: 48px 0 56px; text-align: center; }
.hero .mark { font-weight: 600; letter-spacing: .32em; font-size: 15px; margin-bottom: 26px; padding-left: .32em; }
.hero h1 { font-family: var(--serif); font-weight: 700; font-size: 40px; letter-spacing: .06em; line-height: 1.35; }
.hero p { color: var(--muted); max-width: 560px; margin: 18px auto 0; }
.hero .cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }
.hero .note { font-size: 13px; color: var(--muted); margin-top: 14px; }
.block-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 56px 0 18px; }
.block-title h2 { font-size: 20px; margin: 0; }

.app-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.app-card { display: flex; flex-direction: column; gap: 10px; padding: 24px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s, box-shadow .15s; }
a.app-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.app-card .name { font-weight: 600; letter-spacing: .18em; font-size: 15px; }
.app-card .label { font-family: var(--serif); font-weight: 700; font-size: 20px; letter-spacing: .04em; }
.app-card p { margin: 0; color: var(--muted); font-size: 14px; }
.app-card .foot { margin-top: auto; padding-top: 6px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.app-card .shape { display: flex; align-items: flex-end; gap: 8px; height: 56px; }
.app-card .shape span { display: block; border: 1.5px solid var(--ink-2); border-radius: 4px; }
.app-card .shape .v { width: 30px; height: 54px; }
.app-card .shape .w { width: 96px; height: 54px; }
.app-card.off { opacity: .6; }

/* ---------- plans ---------- */
.plan-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.plan { display: flex; flex-direction: column; padding: 22px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.plan.current { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.plan .pname { font-weight: 600; font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.plan .price { margin: 14px 0 2px; font-size: 28px; font-weight: 600; letter-spacing: -.01em; }
.plan .price small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.plan .per { font-size: 12px; color: var(--muted); min-height: 18px; }
.plan ul { list-style: none; padding: 0; margin: 16px 0 20px; display: grid; gap: 7px; font-size: 13px; }
.plan li { display: flex; gap: 8px; }
.plan li::before { content: ""; flex: none; width: 5px; height: 5px; margin-top: 8px; border-radius: 50%; background: var(--ink-2); }
.plan li.no { color: var(--muted); }
.plan li.no::before { background: transparent; border: 1px solid var(--line-strong); }
.plan li b { font-weight: 600; }
.plan .btn { margin-top: auto; }
.plan-foot { margin-top: 14px; font-size: 13px; color: var(--muted); }
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.pack { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.pack b { display: block; font-weight: 600; }

/* ---------- dashboard ---------- */
.usage-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.usage-big { font-size: 34px; font-weight: 600; letter-spacing: -.01em; }
.usage-big small { font-size: 15px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.meter { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 14px 0 12px; }
.meter > span { display: block; height: 100%; background: var(--ink); border-radius: 99px; transition: width .6s ease; }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--bad); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px 20px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.facts .k { font-size: 12px; color: var(--muted); }
.facts .v { font-weight: 600; margin-top: 2px; }
.ws-switch { display: flex; gap: 8px; align-items: center; }
.ws-switch .select { width: auto; max-width: 240px; padding: 7px 10px; font-size: 14px; }

/* ---------- tables & lists ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -24px; padding: 0 24px; }
table.table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 13px; }
.table td b { white-space: nowrap; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.r, .table th.r { text-align: right; }
.table .nowrap { white-space: nowrap; }
.table .refunded { color: var(--muted); text-decoration: line-through; }
.list-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .who { min-width: 0; }
.list-row .who b { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .who span { font-size: 13px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- legal ---------- */
.legal h1 { margin-bottom: 8px; }
.legal h2 { font-size: 16px; margin: 32px 0 8px; }
.legal p, .legal li { color: var(--ink-2); font-size: 14px; }
.legal dl { display: grid; grid-template-columns: 220px 1fr; margin: 24px 0 0; border-top: 1px solid var(--line); }
.legal dt, .legal dd { margin: 0; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.legal dt { font-weight: 600; padding-right: 16px; }
.legal dd { color: var(--ink-2); }
.todo { color: var(--bad); font-weight: 600; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); padding: 22px max(20px, env(safe-area-inset-left)) calc(22px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.footlinks { display: flex; gap: 8px 20px; flex-wrap: wrap; }
.footlinks a { text-decoration: none; }
.footlinks a:hover { color: var(--ink); }

/* ---------- toast & sheet ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--on-ink); padding: 11px 18px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 15, 18, .72); z-index: 40; display: grid; place-items: center; padding: 20px; overflow: auto; }
.sheet { background: var(--surface); color: var(--ink); border-radius: var(--radius); width: min(480px, 100%);
  max-height: calc(100dvh - 40px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 17px; }
.sheet-body { padding: 20px 22px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .plan-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .section { grid-template-columns: 1fr; gap: 14px; }
  .grid2 { grid-template-columns: 1fr; }
  .legal dl { grid-template-columns: 1fr; }
  .legal dt { border-bottom: 0; padding-bottom: 2px; }
  .legal dd { padding-top: 0; }
}
@media (max-width: 640px) {
  .app { padding: 22px 16px 64px; }
  .topbar { gap: 12px; padding: 0 16px; }
  .brand { letter-spacing: .1em; font-size: 12px; }
  .topnav { gap: 14px; overflow-x: auto; scrollbar-width: none; }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { font-size: 13px; }
  .linkbtn { font-size: 12px; }
  .topright .btn { height: 32px; padding: 0 12px; font-size: 13px; }
  h1 { font-size: 20px; }
  .card.pad { padding: 18px 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .hero { padding: 24px 0 32px; }
  .hero h1 { font-size: 28px; }
  .app-cards, .plan-grid { grid-template-columns: 1fr; }
  .block-title { margin-top: 40px; }
  .list-row { grid-template-columns: 1fr auto; }
  .list-row > :nth-child(3) { grid-column: 1 / -1; justify-self: start; }
  .input, .select, .textarea { font-size: 16px; }   /* keeps iOS from zooming in on focus */
  .footer { padding-left: 16px; padding-right: 16px; }
  .modal-bg { padding: 0; place-items: end stretch; }
  .sheet { width: 100%; border-radius: var(--radius) var(--radius) 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
}

/* --- phone: signed-in menu as a bottom tab bar (same pattern as KIRITORI / YOKONAGA) --- */
@media (max-width: 640px) {
  body.authed .topbar { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none;
                        justify-content: space-between; }   /* a blurred bar would trap the fixed nav */
  body.authed .topnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; flex: none;
    display: flex; gap: 0; overflow: visible; padding: 0 4px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  body.authed .topnav a {
    flex: 1 1 0; min-width: 0; height: 52px; padding: 0 2px; border-bottom: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11.5px; line-height: 1.2; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  body.authed .topnav a.active { color: var(--ink); font-weight: 600; border-bottom: 0; box-shadow: inset 0 2px 0 var(--ink); }
  body.authed { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  body.authed .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .topright .linkbtn { min-height: 40px; display: inline-flex; align-items: center; font-size: 13px; }
  .brand { padding: 12px 0; }   /* logo is a link: give it a thumb-sized target */
  .table-wrap :is(td, th) { white-space: nowrap; }   /* scroll sideways instead of 1-character lines */
  .btn.sm { min-height: 40px; }
}
