:root {
  --bg: #080a0f;
  --surface: #0d1017;
  --surface-2: #121722;
  --surface-3: #171d29;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f7fb;
  --muted: #8f99aa;
  --muted-2: #657084;
  --accent: #8b5cf6;
  --accent-2: #5eead4;
  --danger: #fb7185;
  --success: #34d399;
  --panel-width: 370px;
  --topbar-height: 72px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; min-height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 75% -15%, rgba(139, 92, 246, 0.18), transparent 34%),
    radial-gradient(circle at 15% 110%, rgba(94, 234, 212, 0.08), transparent 32%),
    var(--bg);
}
button, input, select { font: inherit; }
button { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app { min-height: 100vh; }
.topbar {
  height: var(--topbar-height);
  display: grid;
  grid-template-columns: var(--panel-width) 1fr auto;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 10, 15, 0.86);
  backdrop-filter: blur(24px);
  position: relative;
  z-index: 40;
}
.brand {
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
  border-right: 1px solid var(--line);
}
.brand-mark {
  width: 38px;
  height: 38px;
  padding: 7px;
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
  background: linear-gradient(145deg, rgba(139,92,246,.95), rgba(83,53,174,.8));
  box-shadow: 0 8px 30px rgba(139,92,246,.22), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-mark span { border-radius: 2px; background: rgba(255,255,255,.92); }
.brand-mark span:first-child { grid-row: span 2; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.08; }
.brand-copy strong { font-size: 18px; letter-spacing: -.03em; }
.brand-copy small { margin-top: 5px; color: var(--muted-2); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.topbar-center {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .04em;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(52,211,153,.08); }
.topbar-actions { display: flex; align-items: center; gap: 8px; padding-right: 18px; }

.ghost-button, .icon-button, .secondary-button, .primary-button, .pane-icon-button {
  border: 0;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease, color .18s ease, opacity .18s ease;
}
.ghost-button {
  height: 38px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255,255,255,.025);
  font-size: 12px;
}
.ghost-button svg { width: 16px; }
.ghost-button:hover, .icon-button:hover { color: var(--text); border-color: var(--line-strong); background: rgba(255,255,255,.06); }
.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.025);
  color: var(--muted);
}
.icon-button svg { width: 17px; height: 17px; }

.main-shell { height: calc(100vh - var(--topbar-height)); display: grid; grid-template-columns: var(--panel-width) 1fr; }
.control-panel {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 22px 110px;
  border-right: 1px solid var(--line);
  background: rgba(11, 14, 20, 0.88);
  scrollbar-color: var(--surface-3) transparent;
  scrollbar-width: thin;
  position: relative;
  z-index: 30;
}
.control-panel::-webkit-scrollbar { width: 8px; }
.control-panel::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 29px; }
.eyebrow, .section-kicker { margin: 0; color: var(--accent-2); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.panel-head h1 { margin: 7px 0 0; font-size: 23px; letter-spacing: -.04em; }
.settings-section { padding: 22px 0; border-top: 1px solid var(--line); }
.settings-section:first-of-type { border-top: 0; padding-top: 0; }
.section-title-row { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.section-title-row h2 { margin: 4px 0 0; font-size: 14px; letter-spacing: -.01em; }
.section-kicker { color: var(--accent); }
.helper { max-width: 150px; color: var(--muted-2); font-size: 10px; text-align: right; }
.url-list { display: grid; gap: 10px; }
.url-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.018);
  transition: border-color .2s ease, background .2s ease;
}
.url-item:focus-within { border-color: rgba(139,92,246,.48); background: rgba(139,92,246,.035); }
.url-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.slot-number {
  width: 22px; height: 22px; display: grid; place-items: center;
  border-radius: 7px; background: var(--surface-3); color: var(--muted); font-size: 10px; font-weight: 800;
}
.slot-label { color: #cfd5df; font-size: 11px; font-weight: 700; }
.service-pill {
  margin-left: auto; padding: 4px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted-2); font-size: 9px; font-weight: 800; letter-spacing: .04em;
}
.service-pill.youtube { color: #ff9aa7; background: rgba(255,75,96,.1); }
.service-pill.twitch { color: #c4a5ff; background: rgba(145,70,255,.12); }
.service-pill.web { color: #83e7d9; background: rgba(94,234,212,.1); }
.input-shell { position: relative; display: flex; align-items: center; }
.input-shell > svg { position: absolute; left: 11px; width: 15px; color: var(--muted-2); pointer-events: none; }
.url-input, .name-input, .session-mode {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; outline: 0; color: var(--text); background: var(--surface); transition: border-color .18s ease, background .18s ease;
}
.url-input { height: 39px; padding: 0 34px 0 35px; font-size: 11px; }
.url-input::placeholder, .name-input::placeholder { color: #505a6d; }
.url-input:focus, .name-input:focus, .session-mode:focus { border-color: rgba(139,92,246,.58); background: #0f131c; }
.clear-input { position: absolute; right: 7px; width: 26px; height: 26px; padding: 5px; display: none; border: 0; border-radius: 7px; background: transparent; color: var(--muted-2); cursor: pointer; }
.clear-input svg { width: 100%; }
.url-item.has-value .clear-input { display: grid; place-items: center; }
.url-options { margin-top: 8px; display: grid; grid-template-columns: 1fr 1.25fr; gap: 7px; }
.name-input, .session-mode { height: 34px; padding: 0 9px; font-size: 10px; }
.session-mode { cursor: pointer; }
.mode-help { display: none; margin: 8px 2px 0; color: var(--muted-2); font-size: 9px; line-height: 1.55; }
.url-item.mode-special .mode-help { display: block; }
.layout-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.layout-option {
  min-height: 68px; padding: 8px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.018); cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between; gap: 6px; color: var(--muted-2); transition: all .18s ease;
}
.layout-option:hover { border-color: var(--line-strong); color: var(--muted); transform: translateY(-1px); }
.layout-option.active { border-color: rgba(139,92,246,.65); color: #d9ccff; background: rgba(139,92,246,.1); box-shadow: inset 0 0 0 1px rgba(139,92,246,.08); }
.layout-thumb { width: 100%; height: 34px; display: grid; gap: 3px; }
.layout-thumb span { min-width: 0; min-height: 0; border-radius: 3px; background: currentColor; opacity: .52; }
.layout-option.active .layout-thumb span:first-child { opacity: 1; }
.layout-option small { font-size: 8px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb-one { grid-template: 1fr / 1fr; }
.thumb-split-h { grid-template: 1fr / repeat(2,1fr); }
.thumb-split-v { grid-template: repeat(2,1fr) / 1fr; }
.thumb-three-left { grid-template: repeat(2,1fr) / 1.5fr 1fr; }
.thumb-three-left span:first-child { grid-row: span 2; }
.thumb-three-right { grid-template: repeat(2,1fr) / 1fr 1.5fr; }
.thumb-three-right span:first-child { grid-column: 2; grid-row: span 2; }
.thumb-three-right span:nth-child(2) { grid-column: 1; grid-row: 1; }
.thumb-three-right span:nth-child(3) { grid-column: 1; grid-row: 2; }
.thumb-three-top { grid-template: 1.5fr 1fr / repeat(2,1fr); }
.thumb-three-top span:first-child { grid-column: span 2; }
.thumb-three-cols { grid-template: 1fr / repeat(3,1fr); }
.thumb-four-grid { grid-template: repeat(2,1fr) / repeat(2,1fr); }
.thumb-four-left { grid-template: repeat(3,1fr) / 1.55fr 1fr; }
.thumb-four-left span:first-child { grid-row: span 3; }
.thumb-four-top { grid-template: 1.55fr 1fr / repeat(3,1fr); }
.thumb-four-top span:first-child { grid-column: span 3; }
.thumb-four-cols { grid-template: 1fr / repeat(4,1fr); }
.compact-section { padding-bottom: 4px; }
.notice-card { padding: 12px; display: grid; grid-template-columns: 18px 1fr; gap: 10px; border: 1px solid rgba(251,191,36,.13); border-radius: 12px; background: rgba(251,191,36,.035); }
.notice-card > svg { width: 17px; color: #fbbf24; }
.notice-card strong { display: block; margin-bottom: 4px; font-size: 10px; color: #d9d0ba; }
.notice-card p { margin: 0; color: var(--muted-2); font-size: 9px; line-height: 1.55; }
.panel-footer {
  position: fixed; left: 0; bottom: 0; width: var(--panel-width); padding: 16px 22px 17px; border-right: 1px solid var(--line); border-top: 1px solid var(--line); background: linear-gradient(to top, #0b0e14 76%, rgba(11,14,20,.92)); z-index: 35;
}
.primary-button {
  width: 100%; height: 47px; padding: 0 17px; display: flex; justify-content: space-between; align-items: center; border-radius: 12px;
  background: linear-gradient(135deg, #7c4dff, #6d3ee5); box-shadow: 0 12px 30px rgba(108,62,229,.24); font-weight: 800; font-size: 12px;
}
.primary-button svg { width: 18px; }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 15px 36px rgba(108,62,229,.32); }
.primary-button:active { transform: translateY(0); }
.panel-footer p { margin: 8px 0 0; color: var(--muted-2); font-size: 9px; text-align: center; }

.app-footer { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.ad-slot { width: 100%; min-height: 90px; overflow: hidden; }
.footer-brand-link { color: var(--muted); font-size: 11px; text-decoration: none; transition: color .18s ease; }
.footer-brand-link strong { color: var(--accent-2); }
.footer-brand-link:hover { color: var(--text); }
.footer-copy { margin: 0; color: var(--muted-2); font-size: 9px; }

.workspace { min-width: 0; display: grid; grid-template-rows: 60px 1fr; background: rgba(4,6,10,.42); position: relative; }
.workspace-toolbar { padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(10,12,18,.52); }
.workspace-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.workspace-icon { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--accent-2); background: rgba(94,234,212,.04); }
.workspace-icon svg { width: 16px; }
.workspace-title > div { min-width: 0; display: flex; flex-direction: column; }
.workspace-title strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-title small { margin-top: 3px; color: var(--muted-2); font-size: 9px; }
.workspace-actions { display: flex; gap: 7px; }
.workspace-actions .icon-button { width: 34px; height: 34px; }
.empty-state { padding: 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; overflow: hidden; }
.empty-visual { width: min(420px, 72%); aspect-ratio: 1.55; margin-bottom: 35px; position: relative; perspective: 900px; }
.mock-pane { position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; background: linear-gradient(145deg, rgba(29,34,48,.95), rgba(13,16,24,.95)); box-shadow: 0 30px 55px rgba(0,0,0,.36); }
.mock-pane::before { content: ""; position: absolute; left: 10px; right: 10px; top: 10px; height: 6px; border-radius: 99px; background: rgba(255,255,255,.055); }
.mock-pane::after { content: ""; position: absolute; inset: 27px 10px 10px; border-radius: 7px; background: radial-gradient(circle at 60% 38%, rgba(139,92,246,.17), transparent 34%), #0a0d13; }
.mock-pane-a { width: 61%; height: 82%; left: 3%; top: 9%; transform: rotateY(9deg) rotateX(2deg); z-index: 3; }
.mock-pane-b { width: 42%; height: 39%; right: 2%; top: 9%; transform: rotateY(-9deg); z-index: 2; }
.mock-pane-c { width: 42%; height: 39%; right: 2%; bottom: 9%; transform: rotateY(-9deg); z-index: 2; }
.empty-glow { position: absolute; left: 22%; right: 10%; bottom: -8%; height: 25%; background: rgba(139,92,246,.26); filter: blur(50px); border-radius: 50%; z-index: 0; }
.empty-state h2 { margin: 8px 0 11px; font-size: clamp(23px,3vw,38px); letter-spacing: -.05em; }
.empty-state > p:last-of-type { max-width: 520px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
.secondary-button { margin-top: 24px; height: 42px; padding: 0 18px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--surface-2); font-size: 12px; }
.pane-grid { min-width: 0; min-height: 0; padding: 10px; display: grid; gap: 10px; overflow: hidden; }
.viewer-pane { min-width: 0; min-height: 0; overflow: hidden; display: grid; grid-template-rows: 43px 1fr; border: 1px solid var(--line); border-radius: 13px; background: #080a0f; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.viewer-pane:fullscreen { border: 0; border-radius: 0; }
.pane-header { min-width: 0; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #141821, #10141c); }
.pane-ident { min-width: 0; display: flex; align-items: center; gap: 8px; }
.pane-number { flex: 0 0 auto; width: 23px; height: 23px; display: grid; place-items: center; border-radius: 7px; color: #d8caff; background: rgba(139,92,246,.14); font-size: 9px; font-weight: 800; }
.pane-copy { min-width: 0; display: flex; flex-direction: column; }
.pane-copy strong { max-width: 220px; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-copy span { max-width: 220px; margin-top: 2px; color: var(--muted-2); font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-actions { display: flex; align-items: center; gap: 4px; }
.pane-mode-badge { margin-right: 2px; padding: 3px 6px; border-radius: 99px; color: var(--muted-2); background: rgba(255,255,255,.045); font-size: 7px; font-weight: 800; white-space: nowrap; }
.pane-mode-badge.instance { color: #d6c7ff; background: rgba(139,92,246,.12); }
.pane-mode-badge.credentialless { color: #92eee1; background: rgba(94,234,212,.09); }
.pane-icon-button { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: transparent; color: var(--muted-2); }
.pane-icon-button:hover { color: var(--text); background: rgba(255,255,255,.07); }
.pane-icon-button svg { width: 13px; }
.frame-wrap { min-width: 0; min-height: 0; position: relative; background: #07090d; }
.viewer-frame { width: 100%; height: 100%; display: block; border: 0; background: #fff; position: relative; z-index: 2; }
.frame-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted-2); z-index: 1; }
.frame-loading span { width: 25px; height: 25px; border: 2px solid rgba(255,255,255,.08); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.frame-loading p { margin: 0; font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }
.frame-tip { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 3; max-width: calc(100% - 20px); padding: 6px 9px; border: 1px solid rgba(255,255,255,.08); border-radius: 8px; color: rgba(255,255,255,.55); background: rgba(5,7,11,.8); backdrop-filter: blur(10px); font-size: 8px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.viewer-pane:hover .frame-tip { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

.layout-one { grid-template: 1fr / 1fr; }
.layout-split-h { grid-template: 1fr / repeat(2, minmax(0, 1fr)); }
.layout-split-v { grid-template: repeat(2, minmax(0, 1fr)) / 1fr; }
.layout-three-left { grid-template: repeat(2, minmax(0, 1fr)) / minmax(0, 1.62fr) minmax(0, 1fr); }
.layout-three-left > :first-child { grid-row: span 2; }
.layout-three-right { grid-template: repeat(2, minmax(0, 1fr)) / minmax(0, 1fr) minmax(0, 1.62fr); }
.layout-three-right > :first-child { grid-column: 2; grid-row: span 2; }
.layout-three-right > :nth-child(2) { grid-column: 1; grid-row: 1; }
.layout-three-right > :nth-child(3) { grid-column: 1; grid-row: 2; }
.layout-three-top { grid-template: minmax(0, 1.62fr) minmax(0, 1fr) / repeat(2, minmax(0, 1fr)); }
.layout-three-top > :first-child { grid-column: span 2; }
.layout-three-cols { grid-template: 1fr / repeat(3, minmax(0, 1fr)); }
.layout-four-grid { grid-template: repeat(2, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr)); }
.layout-four-left { grid-template: repeat(3, minmax(0, 1fr)) / minmax(0, 1.7fr) minmax(0, 1fr); }
.layout-four-left > :first-child { grid-row: span 3; }
.layout-four-top { grid-template: minmax(0, 1.7fr) minmax(0, 1fr) / repeat(3, minmax(0, 1fr)); }
.layout-four-top > :first-child { grid-column: span 3; }
.layout-four-cols { grid-template: 1fr / repeat(4, minmax(0, 1fr)); }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px; color: #dfe5ee; background: rgba(18,23,34,.94); box-shadow: 0 15px 45px rgba(0,0,0,.35); font-size: 11px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.panel-backdrop { display: none; }
.mobile-only { display: none; }

@media (max-width: 980px) {
  :root { --panel-width: 340px; }
  .topbar { grid-template-columns: var(--panel-width) 1fr auto; }
  .topbar-center { display: none; }
  .ghost-button { width: 38px; padding: 0; justify-content: center; }
  .ghost-button svg { width: 17px; }
  .ghost-button { font-size: 0; }
}

@media (max-width: 760px) {
  :root { --topbar-height: 62px; --panel-width: min(91vw, 370px); }
  body { overflow: hidden; }
  .mobile-only { display: inline-grid; }
  .topbar { grid-template-columns: 1fr auto; }
  .brand { padding: 0 16px; border-right: 0; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .brand-copy small { display: none; }
  .topbar-actions { padding-right: 12px; }
  .main-shell { display: block; }
  .control-panel { position: fixed; left: 0; top: var(--topbar-height); bottom: 0; width: var(--panel-width); height: auto; transform: translateX(-105%); transition: transform .24s cubic-bezier(.2,.8,.2,1); box-shadow: 30px 0 80px rgba(0,0,0,.45); }
  .app.panel-open .control-panel { transform: translateX(0); }
  .panel-footer { width: var(--panel-width); }
  .panel-backdrop { position: fixed; inset: var(--topbar-height) 0 0; z-index: 25; background: rgba(0,0,0,.56); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; display: block; transition: opacity .2s ease; }
  .app.panel-open .panel-backdrop { opacity: 1; pointer-events: auto; }
  .workspace { height: calc(100vh - var(--topbar-height)); grid-template-rows: 54px 1fr; }
  .workspace-toolbar { padding: 0 12px; }
  .workspace-title small { display: none; }
  .empty-state { padding: 18px; }
  .empty-visual { width: min(370px, 92%); margin-bottom: 20px; }
  .pane-grid { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 8px; }
  .viewer-pane { flex: 0 0 62vh; min-height: 340px; }
  .pane-mode-badge { display: none; }
  .frame-tip { display: none; }
}

@media (max-width: 440px) {
  .brand-copy strong { font-size: 16px; }
  .topbar-actions { gap: 5px; }
  .topbar-actions .icon-button, .topbar-actions .ghost-button { width: 35px; height: 35px; }
  #resetButton { display: none; }
  .control-panel { padding-left: 16px; padding-right: 16px; }
  .panel-footer { padding-left: 16px; padding-right: 16px; }
  .layout-grid { grid-template-columns: repeat(2, 1fr); }
  .url-options { grid-template-columns: 1fr; }
  .empty-state h2 { font-size: 26px; }
}

/* =========================================================
   Screen separation: Setup mode / Viewer mode
   ========================================================= */
.viewer-actions { display: none; }
.mode-viewer .setup-actions { display: none; }
.mode-viewer .viewer-actions { display: flex; }
body:not(.viewer-active) { overflow: auto; }
.panel-description {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

/* 設定画面：プレビューを表示せず、設定だけを広く使う */
.mode-setup .topbar {
  grid-template-columns: minmax(230px, 300px) 1fr auto;
}
.mode-setup .main-shell {
  min-height: calc(100vh - var(--topbar-height));
  height: auto;
  display: block;
}
.mode-setup .workspace { display: none; }
.mode-setup .control-panel {
  width: 100%;
  min-height: calc(100vh - var(--topbar-height));
  height: auto;
  padding: 42px max(26px, calc((100vw - 1180px) / 2)) 48px;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, .8fr);
  grid-template-areas:
    "head head"
    "urls layout"
    "urls notice"
    "footer footer";
  align-content: start;
  gap: 22px 24px;
  overflow: visible;
  border-right: 0;
  background:
    radial-gradient(circle at 78% 5%, rgba(139,92,246,.13), transparent 28%),
    radial-gradient(circle at 5% 95%, rgba(94,234,212,.05), transparent 26%),
    rgba(8,10,15,.72);
}
.mode-setup .panel-head {
  grid-area: head;
  margin: 0 0 6px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.mode-setup .panel-head h1 { font-size: clamp(28px, 3vw, 42px); }
.mode-setup .control-panel > .settings-section {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(13,16,23,.82);
  box-shadow: 0 18px 60px rgba(0,0,0,.13);
}
.mode-setup .control-panel > .settings-section:nth-of-type(1) { grid-area: urls; }
.mode-setup .control-panel > .settings-section:nth-of-type(2) { grid-area: layout; }
.mode-setup .control-panel > .settings-section:nth-of-type(3) { grid-area: notice; }
.mode-setup .url-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mode-setup .url-item { min-width: 0; background: rgba(255,255,255,.024); }
.mode-setup .layout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mode-setup .compact-section { align-self: start; }
.mode-setup .panel-footer {
  grid-area: footer;
  position: static;
  width: 100%;
  margin-top: 2px;
  padding: 20px 0 0;
  border: 0;
  background: transparent;
}
.mode-setup .panel-footer .primary-button {
  max-width: 430px;
  height: 54px;
  margin: 0 auto;
  padding: 0 22px;
  font-size: 13px;
}
.mode-setup .panel-footer p { font-size: 10px; }

/* ビュー画面：設定領域を完全に隠し、表示領域を最大化 */
.app.mode-viewer {
  --topbar-height: 56px;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: #05070b;
}
.mode-viewer .topbar {
  grid-template-columns: minmax(190px, 260px) 1fr auto;
  background: rgba(6,8,12,.94);
}
.mode-viewer .brand { padding: 0 16px; }
.mode-viewer .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
.mode-viewer .brand-copy strong { font-size: 16px; }
.mode-viewer .brand-copy small { display: none; }
.mode-viewer .control-panel { display: none; }
.mode-viewer .main-shell {
  display: block;
  width: 100%;
  height: calc(100vh - var(--topbar-height));
}
.mode-viewer .workspace {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 1fr;
}
.mode-viewer .workspace-toolbar { display: none; }
.mode-viewer .empty-state { display: none; }
.mode-viewer .pane-grid {
  width: 100%;
  height: 100%;
  padding: 6px;
  gap: 6px;
}
.mode-viewer .viewer-pane {
  grid-template-rows: 36px 1fr;
  border-radius: 9px;
}
.mode-viewer .pane-header { padding: 0 8px; }
.mode-viewer .pane-number { width: 21px; height: 21px; }
.mode-viewer .pane-icon-button { width: 25px; height: 25px; }
.mode-viewer .topbar-actions { padding-right: 12px; }
.mode-viewer .back-button {
  width: auto;
  padding: 0 13px;
  font-size: 11px;
}
.app.mode-viewer:fullscreen,
.app.mode-viewer:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
}

@media (max-width: 980px) {
  .mode-setup .control-panel {
    grid-template-columns: minmax(0, 1.3fr) minmax(270px, .8fr);
    padding-left: 24px;
    padding-right: 24px;
  }
  .mode-setup .url-list { grid-template-columns: 1fr; }
  .mode-viewer .back-button {
    width: auto;
    padding: 0 12px;
    font-size: 11px;
  }
}

@media (max-width: 760px) {
  body:not(.viewer-active) { overflow: auto; }
  .mode-setup .topbar { grid-template-columns: 1fr auto; }
  .mode-setup .topbar-center { display: none; }
  .mode-setup .main-shell { min-height: calc(100vh - var(--topbar-height)); }
  .mode-setup .control-panel {
    position: static;
    width: 100%;
    min-height: calc(100vh - var(--topbar-height));
    height: auto;
    padding: 28px 16px 34px;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "urls"
      "layout"
      "notice"
      "footer";
    gap: 16px;
    overflow: visible;
    transform: none;
    box-shadow: none;
  }
  .mode-setup .panel-head { padding-bottom: 18px; }
  .mode-setup .panel-head h1 { font-size: 29px; }
  .mode-setup .control-panel > .settings-section { padding: 17px; border-radius: 15px; }
  .mode-setup .url-list { grid-template-columns: 1fr; }
  .mode-setup .layout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-setup .panel-footer { position: static; width: 100%; padding: 8px 0 0; }

  .app.mode-viewer { --topbar-height: 54px; }
  .mode-viewer .topbar { grid-template-columns: auto 1fr auto; }
  .mode-viewer .brand { padding: 0 10px; }
  .mode-viewer .brand-copy { display: none; }
  .mode-viewer .topbar-center { display: flex; justify-self: start; font-size: 10px; }
  .mode-viewer .topbar-actions { gap: 5px; padding-right: 8px; }
  .mode-viewer .back-button { width: 36px; padding: 0; font-size: 0; }
  .mode-viewer .pane-grid {
    height: 100%;
    padding: 5px;
    gap: 6px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
  .mode-viewer .viewer-pane { flex: 0 0 62vh; min-height: 330px; }
}
