/* «Капитаны» — рисовая бумага, чёрная тушь, один красный акцент.
   Прямые углы. Без теней, градиентов и скруглений. */

:root {
  --paper: #f4f0e8;
  --card: #ffffff;
  --ink: #141211;
  --ink-soft: #5f594f;
  --line: #ded7c9;
  --line-strong: #141211;
  --shu: #b3001b;
  --on-shu: #f4f0e8;
  --kin: #8a6a2f;
  --muted-cell: #cfc7b8;
  --freeze-cell: #9a9388;
  --ok: #1f6b3a;

  --font-display: 'Oswald', 'Arial Narrow', 'Helvetica Neue', sans-serif;
  --font-body: 'Golos Text', 'Segoe UI', system-ui, sans-serif;
  --font-jp: 'Noto Serif JP', 'Yu Mincho', 'Hiragino Mincho ProN', 'Noto Serif CJK JP', serif;

  --step: 4px;
  --gutter: 16px;
  --nav-h: 66px;
}

[data-theme='dark'] {
  --paper: #0e0d0c;
  --card: #191715;
  --ink: #f2ede4;
  --ink-soft: #a49b8f;
  --line: #332e28;
  --line-strong: #4a443c;
  --shu: #f0525f;
  --on-shu: #14100f;
  --kin: #c9a45e;
  --muted-cell: #2b2723;
  --freeze-cell: #5a544c;
  --ok: #7fc79a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

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

img {
  max-width: 100%;
  display: block;
}

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

/* ---------------------------------------------------------------- shell */

.shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--paper);
  padding-bottom: calc(var(--nav-h) + 20px);
  position: relative;
}

.shell--wide {
  max-width: 1040px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--gutter) 10px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.topbar__title {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 19px;
  letter-spacing: 0.04em;
  margin: 0;
  flex: 1;
}

.topbar__kanji {
  font-family: var(--font-jp);
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--ink-soft);
  display: block;
  line-height: 1;
  margin-bottom: 2px;
}

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
  text-decoration: none;
  position: relative;
}

.iconbtn svg {
  width: 22px;
  height: 22px;
}

.iconbtn__dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 7px;
  height: 7px;
  background: var(--shu);
  border-radius: 50%;
}

.page {
  padding: 18px var(--gutter) 8px;
}

/* ---------------------------------------------------------------- type */

.screen-title {
  font-family: var(--font-display);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 30px;
  line-height: 1.04;
  letter-spacing: 0.01em;
  margin: 4px 0 2px;
}

.screen-kicker {
  font-family: var(--font-jp);
  font-size: 11px;
  letter-spacing: 0.34em;
  color: var(--ink-soft);
  margin: 0 0 6px;
}

.block-title {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 18px;
  letter-spacing: 0.03em;
  margin: 0;
}

.section {
  margin-top: 26px;
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section__link {
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 1px;
}

.muted {
  color: var(--ink-soft);
}

.small {
  font-size: 13px;
}

.tiny {
  font-size: 12px;
  color: var(--ink-soft);
}

.num {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.kanji {
  font-family: var(--font-jp);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
}

.alert-mark {
  color: var(--shu);
}

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--card);
  padding: 16px;
  border: 0;
}

.card + .card {
  margin-top: 10px;
}

.card--ink {
  background: var(--ink);
  color: var(--paper);
}

[data-theme='dark'] .card--ink {
  background: #191715;
  border: 1px solid #453e36;
  color: var(--paper);
}

.card--ink .muted,
.card--ink .tiny,
.card--ink .kanji {
  color: rgba(244, 240, 232, 0.68);
}

[data-theme='dark'] .card--ink .muted,
[data-theme='dark'] .card--ink .tiny,
[data-theme='dark'] .card--ink .kanji {
  color: #a49b8f;
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card__label {
  font-family: var(--font-jp);
  font-size: 11px;
  letter-spacing: 0.3em;
  opacity: 0.7;
  text-transform: uppercase;
}

.stack {
  display: grid;
  gap: 10px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}

.btn--primary {
  background: var(--shu);
  color: var(--on-shu);
  border-color: var(--shu);
}

.btn--ghost {
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn--text {
  padding: 8px 0;
  min-height: 40px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn--block {
  width: 100%;
}

.btn--small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.42;
  cursor: not-allowed;
  text-decoration: none;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-row .btn {
  flex: 1 1 auto;
}

.reason {
  font-size: 13px;
  color: var(--shu);
  margin: 8px 0 0;
}

[data-theme='dark'] .reason {
  color: var(--shu);
}

.hint {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 8px 0 0;
}

/* ---------------------------------------------------------------- belts & stats */

.belt {
  position: relative;
  width: 100%;
  height: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
}

[data-theme='dark'] .belt {
  border-color: #4a443c;
}

.belt--thin {
  height: 6px;
}

.belt__stripe {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 6px;
  transform: translateX(-50%);
}

.belt--thin .belt__stripe {
  width: 4px;
}

.progress {
  height: 3px;
  background: var(--line);
  width: 100%;
  position: relative;
}

.progress__fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--ink);
}

.segments {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.segment {
  width: 22px;
  height: 8px;
  background: var(--line);
}

.segment--on {
  background: var(--ink);
}

.segment--alarm {
  background: var(--shu);
}

/* ---------------------------------------------------------------- lists & rows */

.rows {
  background: var(--card);
  padding: 0 16px;
}

.rows--plain {
  background: transparent;
  padding: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.row:first-child {
  border-top: 0;
}

.row__main {
  flex: 1;
  min-width: 0;
}

.row__title {
  font-weight: 500;
  margin: 0 0 2px;
}

.row__link {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: inherit;
}

.row__chev {
  color: var(--ink-soft);
  font-family: var(--font-display);
}

/* ---------------------------------------------------------------- chips & filters */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  overflow: visible;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.chip--active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.chip select {
  border: 0;
  background: transparent;
  font-size: 13px;
  padding: 0 2px;
  max-width: 150px;
}

[data-theme='dark'] .chip select option {
  background: var(--card);
  color: var(--ink);
}

/* ---------------------------------------------------------------- schedule */

.day {
  margin-top: 20px;
}

.day__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: 10px;
}

.day__wd {
  font-family: var(--font-display);
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.day__date {
  font-size: 13px;
  color: var(--ink-soft);
}

.day__today {
  font-family: var(--font-jp);
  font-size: 11px;
  letter-spacing: 0.2em;
  border: 1px solid var(--shu);
  color: var(--shu);
  padding: 1px 6px;
}

.slot {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.day .slot:first-of-type {
  border-top: 0;
}

.slot__time {
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1;
  letter-spacing: 0.01em;
}

.slot__end {
  display: block;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 3px;
}

.slot__kind {
  font-weight: 600;
  margin: 0 0 2px;
}

.slot__meta {
  font-size: 13px;
  color: var(--ink-soft);
}

.slot__seats {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.04em;
  margin-top: 6px;
}

.slot__seats--full {
  color: var(--shu);
}

.slot__flag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: 1px;
}

/* ---------------------------------------------------------------- tabel (signature) */

.tabel {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-columns: 1fr;
  gap: 2px;
  width: 100%;
}

.tabel__cell {
  aspect-ratio: 1 / 1;
  background: var(--paper);
  border: 1px solid var(--line);
}

[data-state='was'] {
  background: var(--ink);
  border-color: var(--ink);
}

[data-state='freeze'] {
  background: var(--freeze-cell);
  border-color: var(--freeze-cell);
}

[data-state='miss'] {
  background: var(--paper);
  border-color: var(--line);
}

[data-state='future'] {
  background: transparent;
  border-color: var(--line);
  border-style: dashed;
}

.tabel-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-soft);
}

.tabel-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tabel-legend i {
  width: 10px;
  height: 10px;
  display: inline-block;
  border: 1px solid var(--line);
}

/* ---------------------------------------------------------------- misc blocks */

.avatar {
  width: 52px;
  height: 52px;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.04em;
  overflow: hidden;
  flex: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--lg {
  width: 84px;
  height: 84px;
  font-size: 30px;
}

.badge {
  display: inline-block;
  border: 1px solid var(--line-strong);
  padding: 2px 8px;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.badge--alarm {
  border-color: var(--shu);
  color: var(--shu);
}

.badge--ok {
  border-color: var(--ok);
  color: var(--ok);
}

.stat-row {
  display: flex;
  gap: 18px;
}

.stat {
  min-width: 64px;
}

.stat__value {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1;
  display: block;
}

.stat__label {
  font-size: 12px;
  color: var(--ink-soft);
}

.kv {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 6px 12px;
  font-size: 14px;
}

.kv dt {
  color: var(--ink-soft);
  margin: 0;
}

.kv dd {
  margin: 0;
}

.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 16px 0;
}

.quote {
  border-left: 3px solid var(--kin);
  padding-left: 14px;
  font-size: 15px;
}

/* ---------------------------------------------------------------- forms */

.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > label {
  font-size: 13px;
  color: var(--ink-soft);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 15px;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.4;
}

.check input {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--shu);
  flex: none;
}

.check a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--shu);
  color: var(--shu);
  font-size: 14px;
}

.flashes {
  margin: 12px var(--gutter) 0;
  display: grid;
  gap: 8px;
}

.flash {
  padding: 12px 14px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.flash--error {
  background: var(--card);
  color: var(--shu);
  border-left: 3px solid var(--shu);
}

.flash--success {
  background: var(--ink);
  color: var(--paper);
}

.flash__close {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}

/* ---------------------------------------------------------------- nav */

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav__inner {
  max-width: 480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--nav-h);
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.02em;
  border-top: 2px solid transparent;
  padding-top: 2px;
}

.nav__item svg {
  width: 22px;
  height: 22px;
}

.nav__item--active {
  color: var(--ink);
  border-top-color: var(--shu);
}

.nav__item--active svg {
  stroke-width: 2.2;
}

/* ---------------------------------------------------------------- stats grid (admin) */

.grid {
  display: grid;
  gap: 10px;
}

.grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (min-width: 720px) {
  .grid--admin {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--card);
}

table.table th {
  text-align: left;
  font-family: var(--font-display);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

table.table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table-wrap {
  overflow-x: auto;
}

/* ---------------------------------------------------------------- video */

.video {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video__kanji {
  font-family: var(--font-jp);
  font-size: 30px;
  letter-spacing: 0.2em;
}

.video__play {
  width: 44px;
  height: 44px;
  border: 1px solid var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------------------------------------------------------------- empty states */

.empty {
  text-align: center;
  padding: 34px 18px;
  background: var(--card);
}

.empty__title {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 18px;
  margin: 0 0 6px;
}

/* ---------------------------------------------------------------- auth */

.auth {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 20px 40px;
  max-width: 460px;
  margin: 0 auto;
}

.auth__mark {
  font-family: var(--font-jp);
  font-size: 13px;
  letter-spacing: 0.5em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.auth__title {
  font-family: var(--font-display);
  text-transform: uppercase;
  font-size: 38px;
  line-height: 1;
  margin: 0 0 4px;
  letter-spacing: 0.02em;
}

.auth__sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 22px;
}

.demo {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.demo__row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding: 5px 0;
}

.demo code {
  font-family: var(--font-body);
  font-size: 13px;
  background: var(--card);
  padding: 1px 6px;
}

/* ---------------------------------------------------------------- offline */

.offline-mark {
  font-family: var(--font-jp);
  font-size: 64px;
  letter-spacing: 0.1em;
  line-height: 1;
}

/* ---------------------------------------------------------------- theme switch */

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 0;
  min-height: 44px;
}

.switch__track {
  width: 52px;
  height: 28px;
  border: 1px solid var(--line-strong);
  background: transparent;
  position: relative;
  transition: background 120ms linear;
}

.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--ink);
  transition: transform 140ms ease;
}

.switch--on .switch__thumb {
  transform: translateX(24px);
}

/* ---------------------------------------------------------------- utilities */

.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.hide { display: none !important; }

.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  vertical-align: -2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------------------------------------------------- desktop */

@media (min-width: 900px) {
  .shell--wide .page {
    padding: 24px 28px 40px;
  }
}

@media (max-width: 380px) {
  .screen-title { font-size: 26px; }
  .slot { grid-template-columns: 58px 1fr; gap: 10px; }
  .slot__time { font-size: 19px; }
  .tabel { gap: 1px; }
}

/* ---------------------------------------------------------------- admin */

.admin-crumb {
  margin: 0 0 14px;
}

.admin-crumb a {
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
}

.admin-grid {
  display: grid;
  gap: 10px;
}

.admin-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-card--off {
  opacity: 0.62;
}

.admin-card__meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 12px;
  margin: 0;
  font-size: 13px;
}

.admin-card__meta dt {
  color: var(--ink-soft);
  margin: 0;
}

.admin-card__meta dd {
  margin: 0;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: auto;
  padding-top: 4px;
}

.admin-actions .inline-form,
.inline-form {
  display: inline-flex;
  margin: 0;
}

.panel {
  border: 0;
  background: transparent;
}

.panel > summary {
  display: inline-flex;
  cursor: pointer;
  list-style: none;
}

.panel > summary::-webkit-details-marker {
  display: none;
}

.panel > summary::marker {
  content: '';
}

.panel__body {
  margin-top: 10px;
  padding: 16px;
  background: var(--card);
  border-top: 2px solid var(--line-strong);
}

.panel--edit .panel__body {
  background: var(--paper);
  border: 1px solid var(--line);
}

.admin-details {
  font-size: 13px;
  color: var(--ink-soft);
}

.admin-details > summary {
  cursor: pointer;
}

.badge--off {
  border-color: var(--line);
  color: var(--ink-soft);
}

.admin-card .badge {
  flex: none;
}

@media (min-width: 720px) {
  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .admin-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .panel__body .grid--2 {
    grid-template-columns: 1fr;
  }
}
