/* KC 管理画面 */
:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1c1c1c;
  --line: #2a2a2a;
  --text: #f2f2f2;
  --muted: #9a9a9a;
  --red: #f42959;
  --pink: #ff4a95;
  --gold: #d4af37;
  --ok: #3ecf8e;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 "Noto Sans JP", system-ui, sans-serif;
}

a {
  color: var(--pink);
}

h1,
h2,
h3 {
  margin: 0 0 12px;
  line-height: 1.3;
}

h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 17px;
}

h2 small,
.hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.label {
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.18em;
  color: var(--gold);
}

/* ---- 上のバー ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: rgb(10 10 10 / 0.92);
  border-bottom: 2px solid var(--red);
  backdrop-filter: blur(6px);
}

.topbar img {
  height: 32px;
}

.topbar .label {
  font-size: 22px;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  font-size: 14px;
}

.who {
  color: var(--muted);
}

.topbar nav a {
  white-space: nowrap;
}

@media (max-width: 640px) {
  .topbar {
    padding: 10px 16px;
  }

  .topbar .label,
  .who {
    display: none;
  }
}

/* ---- レイアウト ---- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 460px;
  gap: 20px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
}

.col {
  display: grid;
  gap: 20px;
  align-content: start;
}

.sticky {
  position: sticky;
  top: 76px;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }

  .sticky {
    position: static;
  }
}

.panel {
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
}

/* ---- フォーム部品 ---- */
input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 9px 11px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
}

input:focus,
select:focus,
button:focus-visible,
.btn:focus-within {
  outline: 2px solid var(--pink);
  outline-offset: 1px;
}

label.field {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 4px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover,
button:hover {
  filter: brightness(1.1);
}

button:disabled {
  opacity: 0.5;
  cursor: wait;
}

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

.btn--danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgb(244 41 89 / 0.5);
}

.btn--small {
  padding: 5px 10px;
  font-size: 13px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* オン・オフのスイッチ */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  appearance: none;
  position: relative;
  width: 44px;
  height: 24px;
  margin: 0;
  background: #333;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.switch input:checked {
  background: var(--red);
}

.switch input:checked::after {
  transform: translateX(20px);
}

.switch--big input {
  width: 56px;
  height: 30px;
  border-radius: 15px;
}

.switch--big input::after {
  width: 24px;
  height: 24px;
}

.switch--big input:checked::after {
  transform: translateX(26px);
}

.status {
  font-weight: 700;
}

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

.status.is-off {
  color: var(--muted);
}

/* ---- スポンサー一覧 ---- */
.sponsors {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sponsor {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.sponsor.is-off {
  opacity: 0.55;
}

.sponsor__no {
  font-family: "Bebas Neue", sans-serif;
  font-size: 18px;
  color: var(--gold);
}

.sponsor__body {
  display: grid;
  gap: 8px;
}

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

@media (max-width: 640px) {
  .sponsor {
    grid-template-columns: minmax(0, 1fr);
  }

  .sponsor__side {
    grid-auto-flow: column;
    justify-content: start;
  }
}

.thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 26 / 9; /* 配信カードの台紙 (208x72) と同じ比率 */
  width: 100%;
  overflow: hidden;
}

.thumb img {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 86%;
  max-height: 80%;
  object-fit: contain;
}

.thumb--light {
  background: #f4f4f4;
}

.thumb--dark {
  background: #171717;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1);
}

.thumb--empty {
  background: var(--panel-2);
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}

.empty {
  margin: 0;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
}

/* ---- 追加フォーム ---- */
.add-grid {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px;
}

@media (max-width: 640px) {
  .add-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.radio-row {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 14px;
}

/* ---- プレビュー ---- */
.preview {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
}

.preview iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  border: 0;
  transform-origin: 0 0;
  pointer-events: none;
}

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

.copy-row input {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
}

.obs-steps {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
}

/* ---- ログイン ---- */
.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}

.login .panel {
  width: min(380px, 100%);
}

.login header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.login header img {
  height: 44px;
}

.login button {
  width: 100%;
  margin-top: 4px;
}

.error {
  min-height: 1.6em;
  margin: 8px 0 0;
  color: var(--pink);
  font-size: 14px;
}

/* ---- 表 ---- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  color: var(--muted);
  font-weight: 400;
}

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

.role {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  background: #2a2a2a;
}

.role--owner {
  background: rgb(212 175 55 / 0.2);
  color: var(--gold);
}

dialog {
  width: min(380px, calc(100% - 32px));
  padding: 20px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.generated {
  padding: 10px;
  margin: 8px 0 12px;
  background: var(--panel-2);
  border: 1px dashed var(--gold);
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-all;
}

/* ---- 通知 ---- */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  background: #222;
  border-left: 3px solid var(--ok);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.5);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.is-shown {
  opacity: 1;
  transform: none;
}

.toast.is-error {
  border-left-color: var(--red);
}

/* ---- 小さな調整 ---- */
.mt {
  margin-top: 14px;
}

.field--inline {
  max-width: 180px;
  margin: 0;
}

.lead {
  margin-top: -6px;
}

.pick {
  width: 100%;
  margin-top: 8px;
}

h3.sub {
  margin-top: 18px;
  font-size: 15px;
}

.layout--single {
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
}

.narrow {
  max-width: 420px;
}

/* ---- 上のバー (メニュー) ---- */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
}

.topbar nav a:hover {
  color: var(--text);
}

.topbar nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--red);
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
  }

  .topbar .label,
  .who {
    display: none;
  }

  .topbar nav {
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
    gap: 16px;
  }

  .topbar nav button {
    margin-left: auto;
  }
}

/* ---- マイ配信: プリセットのボタン ---- */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.preset {
  display: grid;
  gap: 10px;
  align-content: start;
  justify-content: stretch;
  justify-items: stretch;
  padding: 14px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 400;
  text-align: left;
  white-space: normal;
}

.preset:hover {
  border-color: var(--pink);
  filter: none;
}

.preset.is-active {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px var(--red);
  background: rgb(244 41 89 / 0.08);
  cursor: default;
}

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

.preset__name {
  font-size: 16px;
  font-weight: 700;
}

.preset__badge {
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
}

.logo-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 30px;
}

.mini-thumb {
  position: relative;
  display: inline-block;
  flex: none;
  width: 64px;
  aspect-ratio: 26 / 9; /* 配信カードの台紙 (208x72) と同じ比率 */
  overflow: hidden;
  border-radius: 2px;
}

.mini-thumb img {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 86%;
  max-height: 80%;
  object-fit: contain;
}

.more {
  color: var(--muted);
  font-size: 13px;
}

/* ---- プリセットの編集 ---- */
.grow {
  flex: 1;
  min-width: 0;
}

.preset-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.preset-title {
  flex: 1;
  min-width: 200px;
  font-size: 17px;
  font-weight: 700;
}

.preset-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 12px;
}

@media (max-width: 760px) {
  .preset-body {
    grid-template-columns: minmax(0, 1fr);
  }
}

h3.sub-small {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 400;
}

.order-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.order-row {
  display: grid;
  grid-template-columns: 28px 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.order-row__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-row .row {
  gap: 4px;
  flex-wrap: nowrap;
}

.pick-list {
  display: grid;
  gap: 6px;
}

.pick-sponsor {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: transparent;
  color: var(--text);
  border: 1px dashed var(--line);
  font-weight: 400;
  text-align: left;
}

.pick-sponsor:hover {
  border-color: var(--pink);
  filter: none;
}

.pick-sponsor span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.plus {
  color: var(--pink);
  font-weight: 700;
}

.row.end {
  justify-content: flex-end;
  margin-top: 14px;
}

/* ---- スポンサーのページ / プリセットの表示設定 ---- */
.field--wide {
  max-width: 280px;
}

.sponsor-card {
  list-style: none;
  border-left-width: 1px;
}

.page-list {
  margin-top: 10px;
}

.page-row {
  display: grid;
  grid-template-columns: 28px 150px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.page-row__image {
  display: grid;
  gap: 6px;
}

.page-row__image .thumb--empty {
  font-size: 12px;
}

.page-row__actions {
  gap: 4px;
  flex-wrap: nowrap;
}

@media (max-width: 760px) {
  .page-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .page-row > input,
  .page-row__actions {
    grid-column: 2;
  }
}

.row.between {
  justify-content: space-between;
  margin-top: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0 12px;
  margin-top: 10px;
}
