:root {
  --brand: #0f4c81;
  --brand-2: #d79b23;
  --ink: #17212b;
  --muted: #6c7885;
  --line: #d9e1e8;
  --paper: #ffffff;
  --field: #f7fafc;
  --bg: #edf3f6;
  --danger: #e84855;
  --ok: #1d9a5a;
  --warn: #f29f05;
  --red: #e33a3a;
  --green: #279f58;
  --blue: #2566d8;
  --ios-number-top-height: 18px;
  --ios-number-score-height: 23px;
  --ios-number-cell-height: 44px;
  --ios-zodiac-column-width: 38px;
  color-scheme: light;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% -10%, rgba(15, 76, 129, .20), transparent 28rem),
    radial-gradient(circle at 90% 0%, rgba(215, 155, 35, .18), transparent 22rem),
    var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  background: #e8eef3;
  color: var(--ink);
}

button.warn {
  background: var(--warn);
  color: #1f1b12;
}

button.danger {
  background: var(--danger);
}

button.ok {
  background: var(--ok);
}

button:disabled {
  opacity: .45;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--field);
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

.app {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom));
  --theme-primary: var(--brand);
  --theme-picker-bg: #eef2f6;
  --theme-confirm-bg: #f2dc22;
  --theme-confirm-fg: #111;
  --theme-undo-bg: #22a45a;
  --theme-undo-fg: #111;
  --theme-clear-bg: #ff6fb0;
  --theme-clear-fg: #111;
  --theme-delete-bg: #1aa6a9;
  --theme-delete-fg: #111;
  --theme-add-bg: #f29f05;
  --theme-add-fg: #111;
  --theme-zodiac-bg: transparent;
  --theme-selection-ring: rgba(15, 76, 129, .38);
}

.app.brand-g {
  --theme-primary: #b8852e;
  --theme-picker-bg: #fad9cf;
  --theme-confirm-bg: #9e0d38;
  --theme-confirm-fg: #fff;
  --theme-undo-bg: #d1d6e0;
  --theme-undo-fg: #111;
  --theme-clear-bg: #eb1a6b;
  --theme-clear-fg: #fff;
  --theme-delete-bg: #f51f1f;
  --theme-delete-fg: #fff;
  --theme-add-bg: #ff8f1a;
  --theme-add-fg: #fff;
  --theme-zodiac-bg: #fad9cf;
  --theme-selection-ring: rgba(184, 133, 46, .42);
}

.app.has-fixed-table-tabs {
  padding-bottom: calc(114px + env(safe-area-inset-bottom));
}

.brand-entrance {
  position: relative;
  width: 100vw;
  min-height: 100dvh;
  overflow: hidden;
  background-color: #000;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.brand-entrance-hotspot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72vw;
  height: 46dvh;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 0;
  padding: 0;
  background: rgba(255, 255, 255, .001);
  color: transparent;
}

.activation-gate {
  position: relative;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 32px env(safe-area-inset-bottom);
  display: grid;
  place-items: center;
  background: var(--paper);
}

.activation-admin-button {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 18px;
  z-index: 10;
  padding: 8px 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--theme-primary, var(--brand));
  font-size: 15px;
  font-weight: 700;
}

.activation-panel {
  width: min(440px, 100%);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.activation-spacer {
  min-height: 62px;
}

.activation-panel h1 {
  margin: 0;
  text-align: center;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 900;
}

.activation-contact {
  margin-top: 28px;
  text-align: center;
  color: var(--blue);
  font-size: 20px;
  font-weight: 900;
}

.activation-field-group {
  display: grid;
  gap: 8px;
  margin-top: 26px;
}

.activation-label {
  color: var(--muted);
  font-size: 14px;
}

.activation-device-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 10px 0 12px;
  border-radius: 6px;
  background: #f0f3f6;
}

.activation-device-row code {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 800;
}

.activation-device-row button {
  padding: 7px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--theme-primary, var(--brand));
  font-size: 15px;
}

.activation-code-input {
  height: 46px;
  margin-top: 28px;
  border: 0;
  border-radius: 6px;
  background: #f0f3f6;
  font-size: 17px;
  text-transform: uppercase;
}

.activation-actions-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.activation-actions-row button {
  height: 38px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--blue);
  background: rgba(37, 102, 216, .10);
  font-size: 15px;
}

.activation-actions-row button:disabled {
  color: var(--muted);
  background: #f0f3f6;
}

.activation-submit {
  height: 46px;
  margin-top: 18px;
  border-radius: 6px;
  font-size: 20px;
}

.activation-status {
  min-height: 38px;
  margin-top: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.activation-status.ok {
  color: var(--ok);
}

.activation-tip {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(237, 243, 246, .86);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(217, 225, 232, .8);
  min-width: 0;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: .03em;
  min-width: 0;
}

.brand-title > div:last-child {
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--theme-primary), #17324e);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 76, 129, .22);
}

.system-pill {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 16px;
  background: #dfe9f0;
  flex: 0 0 auto;
}

.system-pill button {
  padding: 7px 12px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
}

.system-pill button.active {
  background: var(--paper);
  color: var(--theme-primary);
  box-shadow: 0 4px 10px rgba(37, 55, 70, .1);
}

.view {
  padding: 14px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  overflow-x: hidden;
}

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

.two-col {
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
}

.home-ios-layout {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.home-input-card {
  padding: 6px;
  padding-bottom: 6px;
}

.home-input-shell {
  position: relative;
  min-width: 0;
}

.home-input-card textarea {
  display: block;
  width: 100%;
  margin: 0;
  padding-right: 74px;
}

.home-input-card textarea:disabled {
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.total-input-hint {
  position: absolute;
  left: 12px;
  right: 74px;
  top: 10px;
  z-index: 1;
  color: rgba(108, 120, 133, .72);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  pointer-events: none;
}

.selected-sequence-input-panel {
  position: absolute;
  left: 8px;
  right: 74px;
  top: 34px;
  z-index: 2;
  display: grid;
  gap: 8px;
  padding: 8px 10px 7px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 12px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 24px rgba(33, 51, 68, .10);
}

.selected-sequence-list {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}

.selected-sequence-empty {
  width: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.selected-sequence-item {
  flex: 1 1 32px;
  min-width: 32px;
  max-width: 46px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.selected-sequence-item.red { background: var(--red); }
.selected-sequence-item.green { background: var(--green); }
.selected-sequence-item.blue { background: var(--blue); }

.selected-sequence-item.text {
  max-width: none;
  padding: 0 8px;
  border-radius: 10px;
  background: #fff4d6;
  color: #8a5500;
  border: 1px solid rgba(242, 159, 5, .32);
}

.selected-sequence-plus {
  color: rgba(108, 120, 133, .9);
  font-size: 18px;
  font-weight: 300;
}

.selected-sequence-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.selected-sequence-actions button {
  min-height: 24px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 900;
}

.selected-sequence-actions button:first-child {
  background: rgba(232, 72, 85, .88);
  color: #fff;
}

.selected-sequence-actions button:last-child {
  background: rgba(108, 120, 133, .82);
  color: #fff;
}

.selected-sequence-show {
  position: absolute;
  left: 12px;
  top: 38px;
  z-index: 2;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  background: rgba(108, 120, 133, .82);
  color: #fff;
  font-size: 12px;
}

.home-system-switch {
  position: absolute;
  right: 0;
  top: 0;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 36px;
  overflow: hidden;
}

.home-system-switch-main,
.home-system-switch-toggle {
  height: 36px;
  border-radius: 0;
  box-shadow: none;
}

.home-system-switch-main {
  width: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #146be8;
  color: #fff;
}

.home-system-switch-main.system-g {
  background: #f07814;
}

.home-system-switch-main .switch-label {
  display: block;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.home-system-switch-toggle {
  width: 20px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: #8cc7ff;
  font-size: 16px;
  font-weight: 900;
}

.home-system-switch.collapsed {
  right: 0;
}

.home-table-card {
  padding: 10px;
  min-width: 0;
  contain: layout paint style;
}

.smart-review-panel {
  padding: 10px;
  display: grid;
  gap: 10px;
  contain: layout paint style;
}

.smart-review-head,
.smart-review-card-head,
.smart-review-actions,
.smart-review-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.smart-review-head,
.smart-review-card-head {
  justify-content: space-between;
}

.smart-review-list {
  display: grid;
  gap: 10px;
}

.smart-review-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid #e2e8ef;
  background: #fff;
}

.failure-sample-panel {
  border-color: #f3d19b;
  background: #fffaf0;
}

.failure-sample-card {
  background: #fffdf8;
}

.smart-failure-section {
  display: grid;
  gap: 8px;
}

.smart-review-divider {
  height: 1px;
  background: #e7edf4;
}

.smart-section-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mini-action {
  min-height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}

.mini-action.primary { background: var(--ok); }
.mini-action.secondary { background: #7c8794; }
.mini-action.info { background: var(--theme-primary, var(--brand)); }
.mini-action.danger { background: var(--danger); }
.mini-action:disabled {
  opacity: .52;
  pointer-events: none;
}

.smart-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
}

.smart-badge.warn {
  background: rgba(242, 159, 5, .16);
  color: #9a6200;
}

.smart-badge.ok {
  background: rgba(41, 181, 123, .16);
  color: #0e8e5b;
}

.smart-badge.danger {
  background: rgba(224, 72, 82, .14);
  color: var(--danger);
}

.smart-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.pending-smart-input {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid #dce4eb;
  background: #f8fafc;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 600;
}

.smart-preview {
  color: #5a6775;
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.smart-preview.strong {
  color: #22313f;
  font-weight: 800;
}

.smart-warning {
  color: #c27a00;
  font-size: 11px;
  line-height: 1.45;
}

.card {
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(217, 225, 232, .9);
  border-radius: 24px;
  padding: 14px;
  box-shadow: 0 16px 40px rgba(33, 51, 68, .08);
  min-width: 0;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  font-weight: 900;
}

.last-input-summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.last-input-summary span {
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(41, 181, 123, .14);
  color: #0e8e5b;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

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

.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

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

.actions.total-actions {
  grid-template-columns: repeat(3, 68px) minmax(0, 1fr);
  justify-content: start;
}

.home-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
}

.home-action-row .actions {
  gap: 0;
}

.home-action-row .primary-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.home-action-row .more-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr)) 18px;
}

.home-action-row .more-actions.collapsed {
  grid-template-columns: minmax(0, 1fr) 18px;
}

.more-actions-spacer {
  min-width: 0;
}

.home-input-card .actions .home-more-actions-toggle {
  min-width: 18px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--theme-primary);
  font-size: 16px;
  font-weight: 900;
}

.home-input-card .actions {
  margin-top: 0;
}

.home-input-card .actions button {
  min-height: auto;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: inherit;
  box-shadow: none;
}

.home-input-card .actions #applyInput {
  background: var(--theme-confirm-bg);
  color: var(--theme-confirm-fg);
}

.home-input-card .actions #undoBtn {
  background: var(--theme-undo-bg);
  color: var(--theme-undo-fg);
}

.home-input-card .actions #clearBtn {
  background: var(--theme-clear-bg);
  color: var(--theme-clear-fg);
}

.home-input-card .actions #deleteBtn {
  background: var(--theme-delete-bg);
  color: var(--theme-delete-fg);
}

.home-input-card .actions #addBtn {
  background: var(--theme-add-bg);
  color: var(--theme-add-fg);
}

.table-tabs {
  display: flex;
  overflow-x: auto;
  gap: 0;
  height: 38px;
  margin: 0;
  padding: 5px 10px;
  border-top: 1px solid rgba(0, 0, 0, .08);
  background: var(--theme-picker-bg);
  scrollbar-width: none;
}

.table-tabs::-webkit-scrollbar {
  display: none;
}

.table-tabs button {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 10px;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  box-shadow: none;
}

.table-tabs button.active {
  background: transparent;
  color: var(--theme-primary);
  font-weight: 800;
}

.fixed-table-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(58px + env(safe-area-inset-bottom));
  z-index: 7;
  background: var(--theme-picker-bg);
}

.score-table-wrap {
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  max-height: none;
  min-width: 0;
  contain: layout paint style;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 0;
}

th, td {
  border-bottom: 1px solid #edf1f4;
  padding: 5px;
  text-align: center;
  white-space: normal;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f8fb;
  color: #3c4a56;
  font-size: 12px;
}

.zodiac-cell {
  font-weight: 900;
  background: var(--theme-zodiac-bg, #fafcfe);
  display: grid;
  place-items: center;
  min-width: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
}

.zodiac-cell.selected {
  background: #fff4d6;
  box-shadow: inset 0 0 0 2px var(--theme-selection-ring);
}

.ios-grid-table {
  display: grid;
  width: 100%;
  overflow: hidden;
}

.ios-grid-header,
.ios-grid-row {
  display: grid;
  grid-template-columns: var(--ios-zodiac-column-width) repeat(7, minmax(0, 1fr));
  width: 100%;
}

.ios-grid-header {
  min-height: 25px;
  background: #f4f8fb;
  color: #3c4a56;
  font-size: 11px;
  font-weight: 700;
}

.ios-grid-header > div,
.ios-grid-row > * {
  min-width: 0;
  border-bottom: 1px solid #edf1f4;
}

.ios-grid-header > div {
  display: grid;
  place-items: center;
}

.ios-grid-row {
  min-height: var(--ios-number-cell-height);
}

.ball {
  display: inline-grid;
  place-items: center;
  width: min(30px, 92%);
  height: var(--ios-number-top-height);
  border-radius: 999px;
  color: #fff;
  font-weight: 900;
  margin-bottom: 0;
  padding: 0;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.ball.red { background: var(--red); }
.ball.green { background: var(--green); }
.ball.blue { background: var(--blue); }
.ball.selected {
  box-shadow: 0 0 0 3px rgba(242, 159, 5, .34);
  border-color: #fff;
}

.selected-number-edit,
.number-edit:has(.ball.selected) {
  background: #9b9b9b;
}

.seventh-selected-number-edit,
.number-edit:has(.ball.seventh-selected) {
  background: #ffd1d1;
}

.number-edit {
  display: grid;
  grid-template-columns: 1fr;
  align-content: end;
  align-items: end;
  justify-items: center;
  gap: 1px;
  margin: 0;
  min-width: 0;
  width: 100%;
  height: var(--ios-number-cell-height);
}

.number-edit-empty {
  background: #fafcfe;
}

.score-input {
  width: 100%;
  min-width: 0;
  height: var(--ios-number-score-height);
  padding: 0 1px;
  text-align: center;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: var(--ios-number-score-height);
}

.row-score-input {
  align-self: end;
  justify-self: stretch;
  margin-bottom: 1px;
}

.row-score-input.selected {
  background: #fff4d6;
  border-color: rgba(242, 159, 5, .78);
  box-shadow: inset 0 0 0 1px rgba(242, 159, 5, .5);
}

.zero-value {
  font-weight: 400 !important;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px;
}

.summary-blocks {
  display: grid;
  gap: 8px;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
}

.summary-row-title {
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #edf4fa;
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  writing-mode: vertical-rl;
  letter-spacing: .12em;
}

.summary-row-items {
  display: grid;
  gap: 4px;
}

.summary-row-single .summary-row-items {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.summary-row-double .summary-row-items {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.summary-row-tail .summary-row-items {
  grid-template-columns: repeat(10, minmax(0, 1fr));
}

.summary-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 3px;
  background: #fff;
  min-width: 0;
}

.summary-item strong {
  display: block;
  margin-bottom: 3px;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
}

.summary-item input {
  padding: 5px 2px;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(246, 249, 251, .9);
  border-top: 1px solid rgba(217, 225, 232, .9);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  background: transparent;
  color: var(--muted);
}

.bottom-nav button.active {
  background: var(--theme-primary);
  color: #fff;
}

.notice {
  border-radius: 16px;
  padding: 10px 12px;
  background: #eaf4ff;
  color: #164369;
  font-size: 13px;
}

.settings-form {
  display: grid;
  gap: 14px;
  max-width: 760px;
  margin: 0 auto;
}

.settings-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(217, 225, 232, .9);
  border-radius: 18px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 10px 28px rgba(33, 51, 68, .06);
  content-visibility: auto;
  contain-intrinsic-size: 1px 260px;
}

.settings-section-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.settings-table-picker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: none;
}

.settings-table-picker::-webkit-scrollbar {
  display: none;
}

.settings-table-picker button {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  background: #eef2f6;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.settings-table-picker button.active {
  background: var(--theme-primary, var(--brand));
  color: #fff;
  box-shadow: 0 8px 16px var(--theme-selection-ring, rgba(15, 76, 129, .18));
}

.settings-rows {
  display: grid;
  border-top: 1px solid #edf1f4;
}

.settings-row,
.settings-info-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  min-height: 38px;
  border-bottom: 1px solid #edf1f4;
}

.settings-row span,
.settings-info-row span,
.settings-device span {
  font-size: 15px;
  font-weight: 600;
}

.settings-row input {
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 15px;
  font-weight: 500;
}

.settings-info-row strong {
  min-width: 0;
  text-align: right;
  color: var(--muted);
}

.version-row {
  cursor: pointer;
  user-select: none;
}

.settings-action {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 14px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 800;
}

.settings-action.primary {
  background: var(--theme-primary, var(--brand));
  color: #fff;
}

.settings-action.secondary {
  background: #eef2f6;
  color: var(--ink);
}

.settings-action.destructive {
  background: var(--danger);
  color: #fff;
}

.settings-action.compact {
  min-height: 34px;
  border-radius: 10px;
  font-size: 13px;
}

.archive-entry-action {
  grid-template-columns: minmax(0, 1fr) auto;
  place-items: center stretch;
  text-align: left;
}

.archive-entry-action small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.archive-detail-page {
  padding-bottom: 12px;
}

.archive-detail-header {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.archive-detail-header .settings-action {
  min-width: 74px;
}

.settings-actions-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.segmented-control {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: #e8edf2;
  overflow: hidden;
}

.segmented-control button {
  min-height: 32px;
  padding: 0 6px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  box-shadow: none;
}

.segmented-control button.active {
  background: #fff;
  color: var(--theme-primary, var(--brand));
  box-shadow: 0 2px 8px rgba(25, 38, 52, .12);
}

.settings-file-label input {
  display: none;
}

.settings-file-label.disabled {
  opacity: .45;
  pointer-events: none;
}

.settings-code,
.settings-device code {
  display: block;
  overflow-wrap: anywhere;
  border-radius: 12px;
  background: #f6f8fa;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
}

.settings-copy-fallback {
  min-height: 112px;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.settings-device {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.settings-footer,
.settings-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.settings-detail-box,
.usage-guide {
  display: grid;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: #f6f8fa;
}

.admin-login-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .32);
  backdrop-filter: blur(8px);
}

.admin-login-card {
  display: grid;
  gap: 12px;
  width: min(360px, 100%);
  padding: 18px;
  border-radius: 18px;
  background: #f7f9fb;
  box-shadow: 0 18px 52px rgba(15, 23, 42, .22);
}

.admin-login-card input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #e1e7ee;
  border-radius: 12px;
  padding: 0 12px;
  font-size: 16px;
  background: #fff;
}

.ios-alert-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 18, 28, .26);
  backdrop-filter: blur(10px);
}

.ios-alert-card {
  width: min(284px, 100%);
  overflow: hidden;
  border-radius: 15px;
  background: rgba(247, 248, 250, .96);
  box-shadow: 0 20px 60px rgba(15, 23, 42, .24);
  text-align: center;
}

.ios-alert-title {
  padding: 20px 18px 10px;
  font-size: 17px;
  font-weight: 800;
  color: #111827;
}

.ios-alert-input {
  width: calc(100% - 36px);
  min-height: 39px;
  margin: 0 18px 18px;
  border: 1px solid #cfd6de;
  border-radius: 8px;
  background: #fff;
  padding: 7px 9px;
  font-size: 17px;
  font-weight: 700;
  text-align: left;
}

.ios-alert-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid rgba(60, 60, 67, .20);
}

.ios-alert-button {
  min-height: 46px;
  border-radius: 0;
  background: transparent;
  color: #007aff;
  font-size: 17px;
  font-weight: 500;
}

.ios-alert-button.confirm {
  border-left: 1px solid rgba(60, 60, 67, .20);
  font-weight: 700;
}

.ios-alert-button.cancel {
  color: #007aff;
}

.ios-action-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  align-items: end;
  padding: 0 10px calc(10px + env(safe-area-inset-bottom));
  background: rgba(12, 18, 28, .28);
  backdrop-filter: blur(8px);
}

.ios-action-sheet {
  display: grid;
  gap: 8px;
  width: min(520px, 100%);
  margin: 0 auto;
}

.ios-action-title,
.ios-action-button {
  min-height: 56px;
  border-radius: 14px;
  background: rgba(247, 248, 250, .96);
  box-shadow: 0 10px 36px rgba(15, 23, 42, .16);
}

.ios-action-title {
  display: grid;
  place-items: center;
  padding: 12px;
  color: #6b7280;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.ios-action-button {
  color: #007aff;
  font-size: 20px;
  font-weight: 700;
}

.ios-action-button.destructive {
  color: #ff3b30;
}

.ios-action-button.cancel {
  color: #007aff;
  font-weight: 800;
}

.archive-actions-row {
  margin-top: 2px;
}

.archive-list {
  display: grid;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 2px;
}

.archive-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid #e2e8ef;
  background: #fff;
  content-visibility: auto;
  contain-intrinsic-size: 1px 128px;
}

.archive-card.compact {
  gap: 6px;
}

.archive-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.archive-head strong {
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
}

.archive-head span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.archive-body {
  display: grid;
  gap: 4px;
}

.archive-body p {
  margin: 0;
  color: #3b4856;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.archive-body b {
  display: inline-block;
  min-width: 34px;
  margin-right: 6px;
  color: var(--ink);
}

.archive-correction-input {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid #dce4eb;
  background: #fbfcfe;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.usage-section {
  display: grid;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e7edf3;
}

.usage-section strong {
  color: var(--ink);
  font-size: 14px;
}

.usage-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.usage-section p {
  margin: 0;
  color: #3b4856;
  font-size: 13px;
  line-height: 1.65;
}

.assessment-table th,
.assessment-table td {
  padding: 0;
}

.assessment-page {
  padding: 0;
  overflow: hidden;
}

.assessment-table-tabs {
  display: flex;
  overflow-x: auto;
  height: 30px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.assessment-table-tabs::-webkit-scrollbar {
  display: none;
}

.assessment-table-tabs button {
  flex: 0 0 60px;
  width: 60px;
  height: 30px;
  padding: 0;
  border-radius: 0;
  background: #fff;
  color: #111;
  font-size: 13px;
  font-weight: 400;
}

.assessment-table-tabs button.active {
  color: var(--theme-primary);
  font-weight: 800;
}

.assessment-ios-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 60px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.assessment-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.assessment-field {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  align-items: center;
  min-height: 21px;
  color: #111;
}

.assessment-field span {
  font-size: 12px;
  text-align: center;
}

.assessment-field input,
.assessment-field strong {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0 4px;
  font-size: 17px;
  font-weight: 400;
  text-align: left;
}

.assessment-actions {
  display: grid;
  grid-template-rows: 1fr 1fr;
  border-left: 1px solid var(--line);
}

.assessment-action {
  border-radius: 0;
  background: transparent;
  color: var(--theme-primary, var(--brand));
  padding: 0;
  font-size: 13px;
}

.assessment-action + .assessment-action {
  border-top: 1px solid var(--line);
}

.ios-assessment-table {
  table-layout: fixed;
}

.ios-assessment-table th {
  height: 18px;
  font-size: 12px;
  font-weight: 400;
  background: #fff;
}

.ios-assessment-table td {
  height: 28px;
  font-size: 17px;
  color: #111;
  background: var(--assessment-row-bg, #e7f4f1);
}

.ios-assessment-table tr.selected-assessment-row td {
  border-top: 1px solid #111;
  border-bottom: 1px solid #111;
}

.assessment-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 28px;
  border-radius: 0;
  background: transparent;
  padding: 0;
  font-size: 17px;
  color: #111;
  font-weight: 400;
}

.assessment-number b {
  font-weight: 800;
}

.assessment-number.red b {
  color: var(--red);
}

.assessment-number.green b {
  color: var(--green);
}

.assessment-number.blue b {
  color: var(--blue);
}

.advanced-section {
  display: grid;
  gap: 8px;
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.advanced-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 10px;
  contain: layout paint style;
}

.advanced-card > strong {
  display: block;
  margin-bottom: 6px;
  text-align: center;
  color: var(--theme-primary, var(--brand));
  font-size: 15px;
  font-weight: 900;
}

.advanced-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(56px, 72px);
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid #eef2f5;
  font-size: 15px;
  font-weight: 800;
}

.advanced-row.highlighted {
  margin: 2px -6px;
  border-top-color: rgba(232, 72, 85, .18);
  border-radius: 10px;
  background: rgba(232, 72, 85, .16);
  padding: 6px;
}

.advanced-row.highlighted span {
  color: #9f1823;
}

.advanced-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.advanced-row input {
  height: 28px;
  padding: 0 3px;
  border-radius: 6px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
}

.advanced-row b {
  text-align: center;
}

.advanced-empty {
  color: var(--muted);
}

.selected-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffaf0;
}

.selected-panel-main {
  display: grid;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.selected-panel-title {
  color: #8a5500;
  font-size: 12px;
  font-weight: 900;
}

.selected-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.selected-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px 2px 2px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(242, 159, 5, .32);
  font-size: 12px;
}

.selected-chip.text-chip {
  padding: 5px 9px;
  font-weight: 800;
  color: #8a5500;
}

.status-ok {
  color: var(--ok);
  font-weight: 900;
}

.status-bad {
  color: var(--danger);
  font-weight: 900;
}

.file-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

@media (max-width: 860px) {
  :root {
    --ios-number-top-height: 18px;
    --ios-number-score-height: 23px;
    --ios-number-cell-height: 44px;
    --ios-zodiac-column-width: 34px;
  }

  .topbar {
    gap: 8px;
    padding: 8px 6px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  .brand-title {
    gap: 6px;
    font-size: 13px;
    letter-spacing: 0;
  }

  .brand-title .small {
    max-width: 132px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
  }

  .system-pill {
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
  }

  .system-pill button {
    min-height: 28px;
    padding: 0 7px;
    border-radius: 9px;
    font-size: 12px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .home-input-card .actions.five {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .home-input-card .actions.total-actions {
    grid-template-columns: repeat(3, 68px) minmax(0, 1fr);
    gap: 4px;
  }

  .home-input-card .actions button,
  .home-input-card .actions.five button {
    min-height: 34px;
    padding: 0 2px;
    border-radius: 9px;
    font-size: 12px;
  }

  .home-input-card .actions .home-more-actions-toggle {
    min-height: 34px;
    border-radius: 0;
    font-size: 14px;
  }

  .score-table-wrap {
    max-height: none;
    border: 1px solid var(--line);
    background: #fff;
    overflow: hidden;
  }

  .ios-grid-header,
  .ios-grid-row {
    grid-template-columns: var(--ios-zodiac-column-width) repeat(7, minmax(0, 1fr));
  }

  .ios-grid-header {
    font-size: clamp(8px, 2.4vw, 11px);
  }

  .zodiac-cell {
    display: grid;
    place-items: center;
    min-width: 0;
    font-size: 14px;
    color: var(--theme-primary, var(--brand));
    white-space: nowrap;
  }

  .number-edit {
    grid-template-columns: 1fr;
    margin: 0;
  }

  .ball {
    width: min(30px, 92%);
    height: var(--ios-number-top-height);
    font-size: clamp(12px, 3.2vw, 13px);
    font-weight: 900;
    margin-bottom: 0;
  }

  .score-input {
    width: 100%;
    min-width: 0;
    height: var(--ios-number-score-height);
    padding: 0 1px;
    font-size: clamp(12px, 3.3vw, 14px);
    font-weight: 800;
  }

  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .view {
    padding: 4px;
  }

  .card {
    border-radius: 14px;
    padding: 6px;
  }

  textarea {
    min-height: 150px;
  }

  .summary-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .summary-row-title {
    border-radius: 8px;
    font-size: 10px;
    letter-spacing: .08em;
  }

  .summary-row-items {
    gap: 2px;
  }

  .summary-row-tail .summary-row-items {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }

  .summary-item {
    padding: 3px 1px;
    border-radius: 7px;
  }

  .summary-item strong {
    font-size: clamp(9px, 2.7vw, 11px);
    font-weight: 900;
    margin-bottom: 2px;
    text-align: center;
  }

  .summary-item input {
    padding: 3px 1px;
    border-radius: 6px;
    font-size: clamp(10px, 2.8vw, 12px);
    font-weight: 800;
    text-align: center;
  }

  .assessment-table td {
    border-bottom: 1px solid #edf1f4;
    text-align: center;
    padding: 0;
  }

  .assessment-field {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .assessment-field span {
    font-size: 11px;
  }

  .assessment-field input,
  .assessment-field strong {
    font-size: 15px;
  }

  .settings-actions-row {
    gap: 6px;
  }

  .settings-action {
    min-height: 40px;
    padding: 0 8px;
    border-radius: 12px;
    font-size: 13px;
  }

  .settings-row,
  .settings-info-row {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .settings-device {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 6px;
  }

  .selected-panel {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 360px) {
  :root {
    --ios-zodiac-column-width: 32px;
  }

  .view {
    padding: 3px;
  }

  .card {
    padding: 5px;
  }

  .brand-title .small {
    display: none;
  }

  .actions button,
  .actions.five button {
    font-size: 11px;
  }

  .score-input {
    font-size: 11px;
  }

  .summary-item {
    padding: 2px 0;
  }

  .assessment-ios-panel {
    grid-template-columns: minmax(0, 1fr) 52px;
  }

  .assessment-field {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .assessment-field span {
    font-size: 10px;
  }

  .assessment-field input,
  .assessment-field strong {
    font-size: 13px;
  }
}
