:root {
  --font: "IBM Plex Sans", "PingFang SC", "Noto Sans SC", sans-serif;
  --display: "Syne", "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(16, 36, 31, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--accent); }
button, .btn {
  font: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
}
input, select, textarea {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, white);
  background: #f8fafc;
  color: var(--ink);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  max-width: none;
  padding: 0;
  flex-shrink: 0;
}
textarea { resize: vertical; min-height: 7rem; }
label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink-2);
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
}
label.check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  grid-template-columns: none;
}
label.check > span,
label.check > :not(input) {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.stack { display: grid; gap: 0.75rem; }
.form-grid { max-width: 560px; }
.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}
.filters input, .filters select { width: auto; min-width: 7rem; }
.actions, .actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.table-wrap {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
th, td {
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, white);
  text-align: left;
  vertical-align: top;
}
th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel-2) 80%, white);
}
tr:last-child td { border-bottom: none; }
.empty { padding: 1rem; color: var(--muted); }
.pager {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.mono { font-family: var(--mono); font-size: 0.85rem; }
.muted { color: var(--muted); font-size: 0.8rem; }
.order-error {
  display: inline-block;
  max-width: 36rem;
  line-height: 1.4;
  font-size: 0.85rem;
  white-space: normal;
  word-break: break-word;
  color: var(--danger);
}
.order-error-label {
  font-weight: 600;
}
.order-error-step,
.order-error-msg,
.order-error-popup,
.order-error-hint {
  color: var(--muted);
  font-weight: 400;
}
.order-error-msg {
  color: var(--fg, inherit);
}
.order-error-code {
  display: inline-block;
  margin-top: 0.15rem;
}
.order-remark {
  display: inline-block;
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.hint { color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.err { color: var(--danger); margin: 0.5rem 0 0; font-size: 0.88rem; }
.result {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, white);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, white);
  line-height: 1.5;
  font-size: 0.9rem;
}
.status {
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: #eef2f0;
}
.status.live { background: color-mix(in srgb, var(--ok) 16%, white); color: var(--ok); }
.status.bad { background: color-mix(in srgb, var(--danger) 14%, white); color: var(--danger); }
.status.warn { background: color-mix(in srgb, var(--warn) 18%, white); color: #92400e; }

.btn-primary, .primary {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  font-weight: 600;
}
.btn-primary:hover, .primary:hover { filter: brightness(1.05); }
.ghost, .btn-ghost {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  color: var(--ink-2);
  background: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 0.85rem;
}
.ghost:hover, .btn-ghost:hover { background: #fff; }
.ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.ghost.danger { color: var(--danger); }
.ghost.danger:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }

.pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, white);
  color: var(--accent);
  font-weight: 600;
}

.card-block {
  margin-bottom: 1.4rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed color-mix(in srgb, var(--line) 70%, white);
}
.card-block h3 {
  margin: 0 0 0.4rem;
  font-family: var(--display);
  font-size: 1rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 18, 16, 0.55);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal[hidden],
[hidden] {
  display: none !important;
}
.modal-card {
  width: min(1100px, 96vw);
  height: min(860px, 92vh);
  background: #0f1714;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #2a3b34;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-card.narrow {
  width: min(560px, 96vw);
  max-height: min(88vh, 740px);
  height: auto;
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
  padding-bottom: 0;
  overflow: hidden;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #16201c;
  color: #e8f2ec;
  flex-shrink: 0;
}
.modal-card.narrow .modal-head {
  background: transparent;
  color: var(--ink);
}
.modal-body-scroll {
  padding: 0 1rem 1rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(88vh - 4.5rem);
}
.modal-body-scroll .stack {
  padding: 0;
  overflow: visible;
  max-height: none;
}
.form-section {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem 0;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.form-section:first-child { border-top: 0; padding-top: 0.15rem; }
.form-section h4 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}
.form-section .hint { margin: 0; font-size: 0.78rem; }
.repeat-rows { display: grid; gap: 0.55rem; }
.repeat-row {
  display: grid;
  gap: 0.4rem;
  padding: 0.55rem;
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: 10px;
  min-width: 0;
}
.repeat-row .row-actions {
  display: flex;
  justify-content: flex-end;
}
.game-pick-list {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.55rem;
  min-width: 0;
}
.game-pick-list label.check {
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.stream-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #000;
  min-height: 0;
}
.stream-meta-bar {
  flex-shrink: 0;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #2a3b34;
  display: grid;
  gap: 0.25rem;
}
.stream-meta-bar .hint { margin: 0; }
.stream-link-line {
  margin: 0;
  font-size: 0.78rem;
  color: #9ab0a4;
  overflow-wrap: anywhere;
  word-break: break-all;
  max-width: 100%;
}
.stream-link-card .modal-head {
  position: relative;
  z-index: 2;
}
.stream-link-card .modal-body-scroll {
  max-height: min(50vh, 320px);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
