:root {
  --bg: #f3f6f2;
  --surface: #ffffff;
  --surface-2: #f7faf6;
  --text: #15211a;
  --muted: #647268;
  --faint: #94a29a;
  --line: #e2e9e2;
  --line-strong: #cfdacf;
  --accent: #3f7d58;
  --accent-ink: #ffffff;
  --accent-soft: #e8f3eb;
  --accent-line: #b9d8c4;
  --admin: #c2760a;
  --admin-ink: #ffffff;
  --danger: #c9372c;
  --danger-soft: #fdf2f1;
  --ok: #2f7d4f;
  --ok-soft: #eaf6ee;
  --warn-soft: #fffaeb;
  --warn-line: #fedf89;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.05);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1210;
    --surface: #161d18;
    --surface-2: #1c241e;
    --text: #eff4f0;
    --muted: #a1aea5;
    --faint: #7d8b82;
    --line: #28342c;
    --line-strong: #38473d;
    --accent: #8bcf9f;
    --accent-ink: #0b1710;
    --accent-soft: #1d3325;
    --accent-line: #3d624a;
    --admin: #f0b35a;
    --admin-ink: #1b1206;
    --danger: #ff6b5e;
    --danger-soft: #2b1a1a;
    --ok: #6fd394;
    --ok-soft: #13251b;
    --warn-soft: #2a2413;
    --warn-line: #5c4a1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
  border: 0;
  background: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.app {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  padding: 14px 16px 28px;
  padding-bottom: calc(112px + var(--safe-bottom));
}

.main.no-footer {
  padding-bottom: 32px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------- login ---------------------------------- */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 22px calc(32px + var(--safe-bottom));
  background:
    radial-gradient(1100px 480px at 50% -12%, rgba(63, 125, 88, 0.18), transparent 62%),
    radial-gradient(700px 420px at 100% 110%, rgba(137, 190, 152, 0.14), transparent 60%),
    var(--bg);
}

.login-inner {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.login-brand {
  text-align: center;
  margin-bottom: 26px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #63a37a, #2f6648);
  color: #fff;
  font-weight: 700;
  font-size: 21px;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 24px rgba(47, 102, 72, 0.32);
}

.login-brand .brand-mark {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  font-size: 27px;
  margin-bottom: 16px;
}

.login h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.01em;
}

.login-sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card {
  padding: 20px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 7px;
}

.input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder {
  color: var(--faint);
}

.input.pin {
  letter-spacing: 0.4em;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
}

.input.pin::placeholder {
  letter-spacing: normal;
  font-size: 15px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 16px;
  transition: transform 0.06s, opacity 0.15s, background 0.15s;
  user-select: none;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn.ghost {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
}

.btn.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn.block {
  width: 100%;
}

.btn.small {
  height: 38px;
  padding: 0 13px;
  font-size: 14px;
  border-radius: 10px;
}

.btn.tiny {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
  font-weight: 600;
}

.btn.primary:not(:disabled):hover {
  filter: brightness(0.94);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--muted);
  user-select: none;
  cursor: pointer;
  padding: 4px 0;
}

.checkbox input {
  appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  flex: none;
  position: relative;
}

.checkbox input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox input:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}

.form-error {
  display: none;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}

.form-error.show {
  display: block;
}

.form-error.notice {
  background: var(--ok-soft);
  color: var(--ok);
}

.sheet-message {
  margin: 4px 0 6px;
}

.spacer-14 {
  height: 14px;
}

.member-search {
  width: 100%;
  margin-bottom: 10px;
}

.settings-hint {
  margin: -2px 2px 10px;
}

.settings-note {
  margin: 0 0 8px;
}

.settings-note:last-child {
  margin: 0;
}

.login-foot {
  text-align: center;
  color: var(--faint);
  font-size: 12px;
  margin-top: 18px;
  line-height: 1.7;
}

/* ------------------------------- topbar --------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  min-height: 58px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark.sm {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 15px;
  box-shadow: none;
  flex: none;
}

.brand-text {
  min-width: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.link-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding: 8px;
  border-radius: 8px;
}

.link-btn.muted {
  color: var(--muted);
}

/* ------------------------------- weekbar -------------------------------- */

.weekbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.icon-btn:disabled {
  opacity: 0.35;
}

.week-select {
  flex: 1;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 12px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

/* -------------------------------- days ---------------------------------- */

.day {
  margin-bottom: 18px;
}

.day-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 0 2px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.day-date {
  font-weight: 500;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.day-undecided .day-head {
  color: var(--faint);
}

.act {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.15s, transform 0.06s;
  cursor: pointer;
  outline: none;
}

.act:active {
  transform: scale(0.994);
}

.act:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.act.is-mine {
  border-color: var(--accent-line);
  background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft));
}

.act.is-readonly {
  cursor: default;
}

.act.is-readonly:active {
  transform: none;
}

.act.is-readonly .check {
  display: none;
}

.act.is-mine::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.act-main {
  flex: 1;
  min-width: 0;
}

.act-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.act-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 2px 6px;
  white-space: nowrap;
}

.act.is-mine .act-time {
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}

.act-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.count strong {
  color: var(--text);
  font-weight: 700;
}

.act.is-full .count {
  color: var(--danger);
}

.act.is-full .count strong {
  color: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge.full {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.over {
  background: var(--danger);
  color: #fff;
}

.badge.role {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.off {
  background: var(--surface-2);
  color: var(--faint);
}

.names {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: var(--faint);
  text-align: left;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.names:hover {
  color: var(--muted);
}

.names .me {
  color: var(--accent);
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.chip.me {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 600;
}

.chip-empty {
  font-size: 12px;
  color: var(--faint);
  margin-top: 5px;
}

.check {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: background 0.15s, border-color 0.15s;
}

.check svg {
  width: 15px;
  height: 15px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.12s, transform 0.12s;
  stroke: var(--accent-ink);
}

.act.is-mine .check {
  background: var(--accent);
  border-color: var(--accent);
}

.act.is-mine .check svg {
  opacity: 1;
  transform: scale(1);
}

.history-note {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  font-size: 12.5px;
  color: var(--muted);
}

/* -------------------------------- footer -------------------------------- */

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}

.footer-inner {
  max-width: 620px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-count {
  flex: 1;
  font-size: 13px;
  color: var(--muted);
}

.footer-count b {
  color: var(--text);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.footer .btn {
  min-width: 158px;
}

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

.tabs {
  display: flex;
  gap: 4px;
  padding: 6px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.tab {
  flex: 1;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.tab.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.admin-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-bar .input,
.admin-bar .week-select {
  height: 40px;
  font-size: 13px;
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 0 12px;
  font-size: 14px;
}

.matrix-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: auto;
  max-height: calc(100vh - 288px);
  max-height: calc(100dvh - 288px);
  -webkit-overflow-scrolling: touch;
}

.matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  min-width: 336px;
}

.matrix th,
.matrix td {
  padding: 0;
  border-bottom: 1px solid var(--line);
}

.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 7px 2px;
  text-align: center;
  white-space: nowrap;
}

.matrix thead th .col-count {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

.matrix thead th.is-over .col-count {
  color: var(--danger);
}

.matrix thead th.is-over {
  color: var(--danger);
}

.matrix .name-col {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 124px;
  min-width: 124px;
  max-width: 124px;
  background: var(--surface);
  text-align: left;
  padding: 4px 8px;
  font-weight: 600;
  font-size: 12.5px;
  border-right: 1px solid var(--line);
}

.mx-name {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.mx-nick {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.mx-count {
  flex: none;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.mx-dps {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 1px;
  font-size: 9px;
  font-weight: 500;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.mx-dps-value {
  white-space: nowrap;
}

.mx-tags {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.matrix thead .name-col {
  z-index: 4;
  background: var(--surface-2);
}

.matrix tbody tr:nth-child(even) .name-col {
  background: var(--surface-2);
}

.matrix tbody tr.is-hidden {
  display: none;
}

.cell {
  width: 32.4px;
  height: 32.4px;
  margin: 2.5px auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.cell::after {
  content: '';
  width: 14.4px;
  height: 14.4px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition:
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}

.cell.on::after {
  background: var(--accent);
  box-shadow: none;
}

.cell.on.admin::after {
  background: var(--admin);
  box-shadow: none;
}

.legend {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 2px 10px;
  font-size: 11px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
}

.legend-dot.self {
  background: var(--accent);
}

.legend-dot.admin {
  background: var(--admin);
}

.cell:disabled {
  opacity: 0.55;
}

.matrix-note {
  margin: 10px 2px 0;
  font-size: 12px;
  color: var(--faint);
  line-height: 1.6;
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.member-info {
  flex: 1;
  min-width: 0;
}

.member-name {
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.member-meta {
  font-size: 12px;
  color: var(--faint);
  margin-top: 2px;
}

.member-tags {
  color: var(--accent);
  font-weight: 600;
}

.member-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.member-row.is-hidden {
  display: none;
}

.error-screen .btn {
  margin: 4px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 22px 2px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title:first-child {
  margin-top: 0;
}

.form-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row > * {
  flex: 1;
  min-width: 0;
}

textarea.input {
  height: auto;
  min-height: 112px;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.5;
  font-size: 14px;
}

.hint {
  font-size: 12px;
  color: var(--faint);
  line-height: 1.6;
}

.details {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 0;
  overflow: hidden;
}

.details > summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 14px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.details > summary::after {
  content: "›";
  color: var(--faint);
  font-size: 18px;
  transform: rotate(90deg);
  transition: transform 0.15s;
}

.details[open] > summary::after {
  transform: rotate(-90deg);
}

.details-body {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slot-item {
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.slot-item:last-child {
  border-bottom: 0;
}

.slot-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.slot-name {
  font-weight: 700;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.mini-link {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 5px;
  border-radius: 6px;
}

.mini-link.danger {
  color: var(--danger);
}

.mini-link:active {
  background: var(--surface-2);
}

.add-activity {
  margin-top: 0;
  height: 46px;
  font-size: 14px;
}

.activity-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.data-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.data-actions .btn {
  flex: 1;
}

.activity-actions .btn {
  flex: 1;
  height: 46px;
  font-size: 14px;
}

.sort-mode-hint {
  margin: 8px 2px 0;
}

.sort-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sort-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.sort-index {
  width: 20px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
  flex: none;
}

.sort-info {
  flex: 1;
  min-width: 0;
}

.sort-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sort-meta {
  font-size: 11px;
  color: var(--faint);
  margin-top: 1px;
}

.sort-buttons {
  display: flex;
  gap: 4px;
  flex: none;
}

.sort-buttons button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 16px;
  color: var(--text);
}

.sort-buttons button:disabled {
  opacity: 0.3;
}

.submit-hint {
  margin: 18px 0 4px;
  text-align: center;
  font-size: 12px;
  color: var(--faint);
}

.tag-form {
  gap: 8px;
}

.tag-group {
  margin-top: 4px;
}

.tag-group-label {
  font-size: 11px;
  color: var(--faint);
  margin-bottom: 6px;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  height: 34px;
  min-width: 38px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 14px;
  color: var(--text);
}

.tag-chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.tag-chip:disabled {
  opacity: 0.35;
}

.tag-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.tag-summary {
  font-size: 12px;
  color: var(--muted);
}

.tag-footer .btn {
  min-width: 120px;
  height: 44px;
  flex: none;
}

.slot-name small {
  font-weight: 500;
  font-size: 11px;
  color: var(--faint);
  margin-left: 6px;
}

.slot-cap-hint {
  font-size: 11px;
  color: var(--faint);
}

.slot-controls {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 58px 58px;
  gap: 8px;
  align-items: center;
}

.slot-controls select,
.slot-controls input {
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 0 8px;
  font-size: 13px;
  width: 100%;
  min-width: 0;
}

.slot-controls .mini-save {
  height: 38px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--accent-line);
}

.slot-controls .mini-save:active {
  transform: scale(0.97);
}

.settings-card {
  padding: 14px;
}

.account-link {
  display: block;
  color: var(--text);
}

.account-link-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.account-link::after {
  content: "›";
  float: right;
  color: var(--faint);
  font-size: 20px;
  line-height: 1;
  margin-top: -22px;
}

.dps-input::placeholder {
  font-size: 13px;
}

.pin-warning {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  color: var(--text);
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.55;
}

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.audit-item {
  display: flex;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.5;
}

.audit-item:last-child {
  border-bottom: 0;
}

.audit-time {
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  flex: none;
  width: 84px;
}

.audit-body {
  min-width: 0;
}

.audit-actor {
  color: var(--muted);
}

/* -------------------------------- dialog -------------------------------- */

dialog.sheet {
  width: min(100%, 620px);
  max-width: 620px;
  margin: auto auto 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 -10px 60px rgba(0, 0, 0, 0.28);
}

dialog.sheet::backdrop {
  background: rgba(10, 12, 18, 0.46);
  backdrop-filter: blur(2px);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 8px;
}

.sheet-head h2 {
  font-size: 18px;
  margin: 0;
}

.sheet-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.sheet-body {
  padding: 8px 18px 4px;
  max-height: min(62dvh, 560px);
  overflow: auto;
  font-size: 14px;
  line-height: 1.6;
}

.sheet-actions {
  padding: 14px 18px calc(18px + var(--safe-bottom));
  display: flex;
  gap: 10px;
}

.sheet-actions .btn {
  flex: 1;
  min-width: 0;
  padding: 0 10px;
  font-size: 14px;
}

.code-box {
  margin: 10px 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 260px;
  overflow: auto;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.result-table td,
.result-table th {
  text-align: left;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}

.result-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

/* -------------------------------- toast --------------------------------- */

.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  bottom: auto;
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 300;
  max-width: min(92vw, 520px);
  padding: 11px 16px;
  border-radius: 12px;
  background: #1f2430;
  color: #fff;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.sheet-toast {
  position: absolute;
  top: 62px;
  bottom: auto;
  z-index: 20;
  max-width: calc(100% - 96px);
}

.toast.err {
  background: #b42318;
}

.toast.ok {
  background: #05603a;
}

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

.loading {
  padding: 60px 0;
  text-align: center;
  color: var(--faint);
  font-size: 14px;
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

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

.empty .btn {
  margin-top: 14px;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--faint);
  font-size: 14px;
  line-height: 1.7;
}

.error-screen {
  padding: 80px 24px;
  text-align: center;
}

.error-screen h2 {
  font-size: 18px;
  margin: 0 0 8px;
}

.error-screen p {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 18px;
}

@media (max-width: 359px) {
  .tab {
    font-size: 13px;
  }

  .slot-controls {
    grid-template-columns: 82px minmax(0, 1fr) 54px;
  }

  .slot-controls .mini-save {
    grid-column: 1 / -1;
  }
}

@media (min-width: 700px) {
  .main {
    padding-left: 20px;
    padding-right: 20px;
  }

  .matrix-wrap {
    max-height: calc(100vh - 300px);
    max-height: calc(100dvh - 300px);
  }

  dialog.sheet {
    border-radius: 22px;
    margin: auto;
    width: min(92vw, 560px);
  }

  .sheet-actions {
    padding-bottom: 18px;
  }
}

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