:root {
  color-scheme: dark;
  --background: #101116;
  --surface: #181a22;
  --surface-raised: #20232d;
  --border: #303440;
  --text: #f0f1f6;
  --muted: #b1b6c8;
  --accent: #bca3ff;
  --accent-soft: #29233c;
  --success: #79dfb7;
  --warning: #efcb87;
  --danger: #ff9baf;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
body { margin: 0; background: var(--background); color: var(--text); line-height: 1.6; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.25; }
h2 { font-size: clamp(1.75rem, 3vw, 2.3rem); letter-spacing: -0.04em; margin-bottom: 0.7rem; }
h3 { font-size: 1.05rem; margin-bottom: 0.6rem; }
p { margin-bottom: 1rem; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: #d3c5fa; }
.muted, .field-help { color: var(--muted); }
.muted { font-size: 0.9rem; }
.field-help { font-size: 0.8rem; line-height: 1.65; margin: 0.65rem 0; }
.eyebrow, .nav-label { color: var(--muted); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.eyebrow { margin-bottom: 0.65rem; }

.skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 10; padding: 0.7rem 1rem; background: var(--surface-raised); }
.skip-link:focus { top: 0.5rem; }
.site-header { display: flex; align-items: center; gap: 2rem; padding: 1rem 2rem; border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 0.7rem; font-size: 0.9rem; font-weight: 750; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; background: var(--accent); color: #1c1230; border-radius: 9px; }
.brand-suffix { color: var(--muted); font-weight: 450; }
.site-header h1 { margin: 0; padding-left: 2rem; border-left: 1px solid var(--border); font-size: 0.9rem; font-weight: 500; color: var(--muted); }
.header-label { margin-left: auto; color: var(--muted); font-size: 0.75rem; }
.main-content { max-width: 1560px; min-height: calc(100vh - 140px); margin: 0 auto; }
.studio-layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { align-self: start; position: sticky; top: 0; display: grid; gap: 2rem; padding: 2rem 1rem; max-height: 100vh; overflow-y: auto; }
.nav-label { padding: 0 0.8rem; margin-bottom: 0.6rem; }
.plugin-navigation { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.nav-link { display: flex; align-items: center; gap: 0.65rem; min-height: 46px; padding: 0.6rem 0.8rem; color: var(--muted); border: 1px solid transparent; border-radius: 9px; text-decoration: none; font-size: 0.85rem; }
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link[aria-current] { background: var(--accent-soft); color: #e2d7ff; border-color: #493963; }
.nav-icon { font-size: 1.25rem; width: 1.3rem; text-align: center; }
.nav-link .badge { margin-left: auto; }
.sidebar-note { padding: 0 0.8rem; color: var(--muted); font-size: 0.75rem; }
.sidebar-profile { min-width: 0; }
.sidebar-profile .avatar-frame { width: 36px; height: 36px; border-radius: 9px; }
.sidebar-identity { display: grid; min-width: 0; }
.sidebar-identity strong, .sidebar-identity > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-identity strong { color: var(--text); font-size: 0.85rem; }
.sidebar-identity > span { color: var(--muted); font-size: 0.75rem; }
.workspace { min-width: 0; border-left: 1px solid var(--border); padding: 2.25rem clamp(1rem, 3vw, 3rem) 3rem; }
.workspace-heading { margin-bottom: 1.8rem; }
.workspace-heading > p:last-child { color: var(--muted); font-size: 0.95rem; margin-bottom: 0; }
.plugin-heading { display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: 1rem 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.plugin-heading h2 { margin: 0; }
.overlay-actions { display: grid; justify-items: end; gap: 0.5rem; max-width: 100%; margin-left: auto; text-align: right; }
.overlay-buttons { display: flex; flex-wrap: wrap; justify-content: end; gap: 0.5rem; }
.overlay-actions input { width: 100%; }
.badge { display: inline-block; padding: 0.15rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.65rem; font-weight: 600; line-height: 1.6; vertical-align: middle; letter-spacing: 0; white-space: nowrap; }
.badge-planned { color: var(--muted); background: var(--surface); }
.panel { padding: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading p:last-child { margin-bottom: 0; }

label { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 600; margin-bottom: 0.45rem; }
input, select, textarea { max-width: 100%; border: 1px solid #454a5b; border-radius: 8px; background: #12141b; color: var(--text); }
input, select { min-height: 44px; padding: 0.6rem 0.8rem; font-size: 0.85rem; }
input { min-width: 0; }
textarea { display: block; width: 100%; padding: 1rem; resize: vertical; min-height: 180px; font: 0.85rem/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; }
input::placeholder, textarea::placeholder { color: #8e95ab; opacity: 1; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 44px; padding: 0.65rem 1rem; border: 1px solid transparent; border-radius: 8px; cursor: pointer; text-decoration: none; font-size: 0.85rem; font-weight: 650; line-height: 1.5; text-align: center; }
.button-primary { background: var(--accent); color: #201336; }
.button-primary:hover:not(:disabled) { background: #cebaff; }
.button-secondary { background: var(--surface-raised); color: var(--text); border-color: #454a5b; }
.button-secondary:hover:not(:disabled) { background: #2c303d; border-color: #777f95; }
.button:disabled { opacity: 0.55; cursor: not-allowed; }
.button-copy { background: var(--surface-raised); color: var(--muted); border-color: var(--border); }
.button-copy[data-copy-state="unavailable"] { background: #3b2028; color: var(--danger); border-color: #a45165; opacity: 1; }
.button-copy[data-copy-state="ready"] { background: var(--success); color: #102b21; border-color: var(--success); }
.button-copy[data-copy-state="ready"]:hover { background: #a1edcf; border-color: #a1edcf; }

.preview-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.preview-toolbar p { margin: 0; }
.scenario-field { min-width: 190px; }
.scenario-field select { width: 100%; }
.preview-surface { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.preview-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; padding: 0.6rem 1rem; background: var(--surface); color: var(--muted); font-size: 0.72rem; border-bottom: 1px solid var(--border); }
.preview-viewport {
  width: 100%;
  overflow: auto;
  padding: 20px;
  background-color: #272b36;
  background-image: conic-gradient(#303542 25%, transparent 0 50%, #303542 0 75%, transparent 0);
  background-size: 24px 24px;
}
.preview-viewport:focus-visible { outline-offset: -3px; }
#giveaway-preview-frame {
  display: block;
  box-sizing: content-box;
  width: 900px;
  min-width: 900px;
  max-width: none;
  height: 500px;
  border: 0;
  margin: 0 auto;
  background: transparent;
  outline: 1px solid #697187;
}
.preview-note { color: var(--muted); font-size: 0.8rem; min-height: 1.5rem; margin: 0.85rem 0 1.75rem; }
.editor-actions { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin-top: 1rem; }
.editor-actions .field-help { max-width: 570px; margin: 0; }
.editor-actions .button { flex-shrink: 0; }

.status-pill { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; }
.status-success { color: var(--success); }
.status-danger { color: var(--danger); }
.status-neutral { color: var(--muted); }
.status-dot, .service-status::before { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.feedback { min-height: 1.4rem; font-size: 0.8rem; color: var(--success); margin: 0.65rem 0; overflow-wrap: anywhere; }
.feedback-error { color: var(--danger); }

.profile-panel { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.profile-identity { display: flex; gap: 1rem; align-items: center; min-width: 0; }
.profile-identity > div:last-child { min-width: 0; overflow-wrap: anywhere; }
.profile-identity p, .profile-identity h3 { margin-bottom: 0.2rem; }
.avatar-frame { display: grid; place-items: center; position: relative; width: 56px; height: 56px; flex-shrink: 0; background: var(--accent-soft); border-radius: 12px; overflow: hidden; color: var(--accent); }
.avatar-frame img { width: 100%; height: 100%; object-fit: cover; }
.avatar-frame span { position: absolute; font-size: 1.6rem; }
.status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
.status-card { padding: 1.2rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.status-card dt { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.5rem; }
.status-card dd { margin: 0; font-size: 0.9rem; overflow-wrap: anywhere; }
.service-status { display: inline-flex; align-items: center; gap: 0.5rem; }
.service-status::before { content: ""; background: var(--muted); }
.service-status[data-status="ready"]::before { background: var(--success); }
.service-status[data-status="degraded"]::before { background: var(--warning); }
.service-status[data-status="disabled"]::before { background: var(--danger); }
.session-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: center; margin-top: 2rem; }
.session-panel p { margin-bottom: 0; }
.session-panel .feedback { grid-column: 1 / -1; }
.session-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.confirmation-dialog { width: min(480px, calc(100% - 2rem)); max-height: calc(100% - 2rem); padding: 1.5rem; overflow: auto; background: var(--surface); color: var(--text); border: 1px solid #5b3541; border-radius: var(--radius); }
.confirmation-dialog::backdrop { background: rgb(0 0 0 / 65%); }
.confirmation-dialog h3 { color: var(--danger); }
.confirmation-dialog .session-actions { justify-content: end; margin-top: 1.5rem; }
.session-panel .feedback:empty { display: none; }
.danger-zone { background: #211a20; border-color: #5b3541; }
.danger-zone h3 { color: var(--danger); }
.button-danger { color: var(--danger); background: transparent; border-color: #a45165; }
.button-danger:hover:not(:disabled) { background: #3b2028; border-color: var(--danger); }
.planned-panel { text-align: center; padding: clamp(1.5rem, 5vw, 4rem); }
.planned-panel p { max-width: 550px; margin: 0 auto 1.5rem; color: var(--muted); }
.planned-icon { display: inline-grid; place-items: center; width: 60px; height: 60px; margin-bottom: 1.5rem; background: var(--accent-soft); color: var(--accent); border-radius: 16px; font-size: 2rem; }

.auth-shell { max-width: 640px; margin: 8vh auto; padding: clamp(1.5rem, 5vw, 3rem); }
.auth-panel > p:not(.eyebrow), .error-panel > p:not(.eyebrow) { color: var(--muted); }
.loading-panel { display: flex; gap: 1rem; align-items: center; justify-content: center; }
.loading-panel p { margin: 0; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.site-footer { padding: 1.2rem 2rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.7rem; text-align: right; }
.site-footer span { margin: 0 0.5rem; }

@media (max-width: 1000px) {
  .studio-layout { grid-template-columns: 200px minmax(0, 1fr); }
  .status-grid { grid-template-columns: 1fr; }
  .editor-actions { flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .site-header { padding: 1rem; gap: 1rem; flex-wrap: wrap; }
  .site-header h1 { display: none; }
  .studio-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; display: flex; align-items: start; gap: 1rem; padding: 1rem; max-height: none; overflow-x: auto; border-bottom: 1px solid var(--border); }
  .sidebar nav { flex-shrink: 0; }
  .sidebar-profile { max-width: 220px; }
  .sidebar-note { display: none; }
  .nav-label { margin-bottom: 0.3rem; }
  .plugin-navigation { display: flex; }
  .workspace { border: 0; padding: 1.5rem 1rem 2rem; }
  .auth-shell { margin: 2rem 1rem; }
  .preview-toolbar { align-items: start; flex-wrap: wrap; }
  .panel { padding: 1.2rem; }
}
@media (max-width: 480px) {
  .header-label { display: none; }
  .overlay-actions { width: 100%; justify-items: start; margin-left: 0; text-align: left; }
  .overlay-buttons { justify-content: start; }
  .scenario-field, .editor-actions .button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
}
