:root {
  --bg-0: #060a15;
  --bg-1: #0a0f1e;
  --rail-bg: #070b16;
  --card-bg: #0e1526;
  --card-bg-soft: #0b1220;
  --card-border: rgba(255, 255, 255, 0.07);
  --field-bg: rgba(255, 255, 255, 0.04);
  --field-border: rgba(255, 255, 255, 0.09);
  --text: #e8ecf7;
  --text-dim: #7c88a3;
  --text-faint: #4d5872;
  --accent: #4f8ff7;
  --accent-2: #9b6bff;
  --accent-teal: #22d3c0;
  --success: #34d399;
  --danger: #f87171;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] {
  --bg-0: #eef1f8;
  --bg-1: #e6eaf4;
  --rail-bg: #ffffff;
  --card-bg: #ffffff;
  --card-bg-soft: #f4f6fb;
  --card-border: rgba(20, 30, 60, 0.08);
  --field-bg: #f4f6fb;
  --field-border: rgba(20, 30, 60, 0.12);
  --text: #171e33;
  --text-dim: #6b7590;
  --text-faint: #a2abc4;
  --shadow-card: 0 10px 26px rgba(30, 40, 80, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(1200px 700px at 90% -12%, rgba(79, 143, 247, 0.16), transparent 55%),
    radial-gradient(900px 620px at -8% 108%, rgba(155, 107, 255, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  transition: background 0.2s ease, color 0.2s ease;
}

.hidden { display: none !important; }
.muted { color: var(--text-dim); font-weight: 400; }
.required { color: #ef4444; font-weight: 700; }
.optional { color: var(--muted, #8a93a6); font-weight: 500; font-size: 0.85em; }
.muted-sm { color: var(--text-dim); font-size: 12px; margin: 2px 0 0; }
button { font-family: inherit; }
svg { display: block; }

.login-screen { height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  width: 320px; max-width: 92vw; padding: 28px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card); text-align: center;
}
.login-card h1 { font-size: 18px; margin: 0 0 8px; }
.login-card p { color: var(--text-dim); margin: 0 0 16px; }
#login-username, #login-password { width: 100%; margin-bottom: 12px; }
.error-text { color: var(--danger); font-size: 12px; margin-top: 10px; }
.success-text { color: var(--success); font-size: 12px; margin-top: 10px; }

.signup-card { width: 360px; }
.signup-card .field { width: 100%; margin-bottom: 10px; }
.auth-switch-link { display: block; width: 100%; margin-top: 14px; font-size: 12.5px; text-align: center; }
.auth-switch-link:hover { color: var(--accent); }
.captcha-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.captcha-question {
  flex: none; min-width: 64px; text-align: center; padding: 9px 10px;
  background: var(--field-bg); border: 1px solid var(--field-border);
  border-radius: 10px; font-weight: 700; letter-spacing: 0.3px;
}
.captcha-row .captcha-input { flex: 1; margin-bottom: 0; text-align: center; }
.captcha-row .btn-icon { flex: none; }

.brand-logo { width: 42px; height: 42px; border-radius: 12px; object-fit: contain; flex: none; }
.logo-light-img { display: none; }
[data-theme="light"] .logo-dark-img { display: none; }
[data-theme="light"] .logo-light-img { display: inline; }
.brand-logo-lg { width: 64px; height: 64px; object-fit: contain; margin: 0 auto 14px; border-radius: 16px; }
.logo-lg { width: 60px; height: 60px; font-size: 26px; margin: 0 auto 14px; }
.login-card .brand-logo-lg { display: block; }

.maintenance-card { width: 380px; max-width: 92vw; padding: 34px 30px; }
.maint-img { display: block; max-width: 100%; max-height: 160px; object-fit: contain; margin: 0 auto 14px; border-radius: 12px; }
.maintenance-card h1 { font-size: 20px; }
.maintenance-card p { line-height: 1.55; white-space: pre-line; }
.maint-staff { margin-top: 6px; font-size: 11.5px; color: var(--text-faint); }
.maint-staff:hover { color: var(--text-dim); }
.maint-banner {
  flex: none; padding: 7px 16px; text-align: center; font-size: 12px; font-weight: 600;
  background: rgba(245,185,66,0.16); color: #f5b942; border-bottom: 1px solid rgba(245,185,66,0.3);
}

.maint-popup-card { width: 360px; max-width: 92vw; text-align: center; padding: 30px 26px; }
.maint-popup-card .maint-popup-icon { font-size: 30px; margin-bottom: 10px; }
.maint-popup-card h2 { font-size: 17px; margin: 0 0 8px; }
.maint-popup-card p { color: var(--text-dim); line-height: 1.55; white-space: pre-line; margin: 0 0 18px; }

.notif-wrap { position: relative; }
#notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--card-bg-soft);
}
.notif-panel {
  position: absolute; top: calc(100% + 10px); right: 0; width: 340px; max-width: 92vw;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card); z-index: 30; overflow: hidden;
}
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--card-border); font-size: 13px; }
.notif-readall:hover { color: var(--accent); }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-empty { padding: 22px 14px; text-align: center; }
.notif-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--card-border); cursor: pointer; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--field-bg); }
.notif-item.unread { background: rgba(79,143,247,0.07); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--text-faint); }
.notif-item.unread .notif-dot { background: var(--accent); }
.notif-item.k-success.unread .notif-dot { background: var(--success); }
.notif-item.k-warning.unread .notif-dot { background: #f5b942; }
.notif-body { min-width: 0; flex: 1; }
.notif-title { font-size: 13px; font-weight: 700; }
.notif-msg { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.notif-time { font-size: 11px; color: var(--text-faint); margin-top: 4px; }

.notif-item-link { font-size: 11.5px; color: var(--accent); margin-top: 3px; }

.notif-detail-card { width: 560px; max-width: 92vw; padding: 0; overflow: hidden; text-align: center; }
.notif-detail-card .modal-close {
  z-index: 2; background: rgba(10,14,26,0.35); width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff; top: 12px; right: 12px;
}
.notif-detail-card .modal-close:hover { background: rgba(10,14,26,0.55); color: #fff; }

.notif-detail-banner {
  position: relative; padding: 34px 24px 26px; overflow: hidden;
  background: linear-gradient(135deg, #3a6dfb, #7b5cff);
}
.notif-detail-banner::before, .notif-detail-banner::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(2px); opacity: 0.35; pointer-events: none;
}
.notif-detail-banner::before { width: 140px; height: 140px; background: rgba(255,255,255,0.18); top: -60px; left: -40px; }
.notif-detail-banner::after { width: 110px; height: 110px; background: rgba(255,255,255,0.14); bottom: -50px; right: -30px; }
.notif-detail-banner.k-success { background: linear-gradient(135deg, #12996a, #22d3c0); }
.notif-detail-banner.k-warning { background: linear-gradient(135deg, #e08a1e, #ef4444); }

.notif-detail-icon {
  position: relative; z-index: 1; width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 22px;
  background: rgba(255,255,255,0.95); display: flex; align-items: center; justify-content: center;
  font-size: 34px; box-shadow: 0 10px 24px rgba(0,0,0,0.25); overflow: hidden;
}
.notif-detail-icon img { width: 100%; height: 100%; object-fit: cover; }

.notif-detail-heading {
  position: relative; z-index: 1; margin: 0; font-size: 18px; font-weight: 800; color: #fff;
  line-height: 1.35; overflow-wrap: anywhere; text-shadow: 0 1px 6px rgba(0,0,0,0.2);
}

.notif-detail-body { padding: 22px 22px 24px; text-align: left; }
.notif-detail-fromadmin { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.notif-detail-fromadmin-label { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); }
.notif-detail-kind {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: rgba(79,143,247,0.14); color: var(--accent);
}
.notif-detail-kind.k-success { background: rgba(46,196,133,0.14); color: var(--success); }
.notif-detail-kind.k-warning { background: rgba(245,185,66,0.16); color: #f5b942; }

.notif-detail-message {
  color: var(--text-dim); line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere;
  margin: 0 0 14px; max-height: 30vh; overflow-y: auto; background: var(--field-bg);
  border: 1px solid var(--field-border); border-radius: 12px; padding: 12px 14px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.notif-detail-message::-webkit-scrollbar { width: 5px; }
.notif-detail-message::-webkit-scrollbar-track { background: transparent; }
.notif-detail-message::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 4px; }
.notif-detail-message:empty { display: none; }

.notif-detail-video { margin: 0 0 16px; }
.notif-video-thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 16/9; border-radius: 12px; overflow: hidden;
  background-size: cover; background-position: center; background-color: #0a0f1e; border: none; cursor: pointer; padding: 0;
}
.notif-video-thumb::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,0.25); }
.notif-video-play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1;
  width: 52px; height: 52px; border-radius: 50%; background: rgba(20,24,38,0.78); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 18px; padding-left: 3px;
}
.notif-detail-video-embed iframe { width: 100%; aspect-ratio: 16/9; border-radius: 12px; border: none; display: block; }
.notif-detail-video-url { display: block; margin-top: 8px; font-size: 12px; color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }

.notif-detail-link { margin-bottom: 10px; }
.notif-detail-time { margin-bottom: 14px; }

.app-shell { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 76px; min-height: 76px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--card-border);
  background: var(--card-bg-soft);
}
.brand-block { display: flex; align-items: center; gap: 12px; flex: none; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 18px;
  box-shadow: 0 6px 18px rgba(79, 143, 247, 0.35);
}
.brand-block h1 { font-size: 17px; margin: 0; font-weight: 700; }
.accent-text { background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.subtitle { margin: 1px 0 0; font-size: 12px; color: var(--text-dim); }

.badge-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(34, 211, 192, 0.14); color: var(--accent-teal);
  border: 1px solid rgba(34, 211, 192, 0.3);
}
.badge-pill.small { padding: 4px 10px; font-size: 11px; background: rgba(79,143,247,0.14); color: var(--accent); border-color: rgba(79,143,247,0.3); }
.count-pill {
  display: inline-flex; align-items: center; height: 38px; padding: 0 14px;
  border-radius: 10px; background: var(--field-bg); border: 1px solid var(--field-border);
  color: var(--text); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.tagline { color: var(--text-dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-gap { flex: 1; display: flex; align-items: center; justify-content: center; gap: 14px; min-width: 0; padding: 0 16px; }
.ai-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px; font-size: 12px; font-weight: 700;
  color: var(--accent-2);
  background: linear-gradient(90deg, rgba(79,143,247,0.14), rgba(155,107,255,0.14));
  border: 1px solid rgba(155, 107, 255, 0.3);
}
.ai-badge svg { width: 14px; height: 14px; }

.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.topbar-right .btn { flex: none; white-space: nowrap; text-decoration: none; }

.topbar-right > * { flex-shrink: 0; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--field-bg); border: 1px solid var(--field-border);
  color: var(--text-dim); cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.08); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn-credits {
  width: auto; padding: 0 14px; gap: 8px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-dim); white-space: nowrap;
}
.icon-btn-addcredits {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; height: 38px;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.icon-btn-addcredits svg { width: 15px; height: 15px; }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
}
.avatar-wrap { position: relative; }
.avatar-sm { width: 30px; height: 30px; font-size: 12px; flex: none; }
.profile-menu {
  position: absolute; top: calc(100% + 10px); right: 0; width: 220px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card);
  padding: 8px; z-index: 30;
}
.profile-menu-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; }
.profile-name { font-size: 13px; font-weight: 700; }
.profile-sub { font-size: 11px; color: var(--text-dim); }
.profile-menu-divider { height: 1px; background: var(--card-border); margin: 6px 0; }
.profile-menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: none; border: none; color: var(--text); font-size: 13px;
  padding: 9px 8px; border-radius: 8px; cursor: pointer; text-align: left;
}
.profile-menu-item svg { width: 16px; height: 16px; flex: none; }
.profile-menu-item:hover { background: var(--field-bg); }
.profile-menu-item.danger { color: var(--danger); }

.body-row { flex: 1; display: flex; min-height: 0; }
.rail {
  width: 84px; min-width: 84px;
  background: var(--rail-bg); border-right: 1px solid var(--card-border);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px 10px;
}
.rail-btn {
  width: 100%; padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; border-radius: 12px; cursor: pointer;
  color: var(--text-dim); font-size: 11px;
}
.rail-btn { text-align: center; }
.rail-btn span { display: block; width: 100%; text-align: center; line-height: 1.25; overflow-wrap: break-word; }
.rail-btn svg { width: 20px; height: 20px; flex: none; }
.rail-btn:hover { background: var(--field-bg); color: var(--text); }
.rail-btn.active { background: linear-gradient(135deg, rgba(79,143,247,0.18), rgba(155,107,255,0.18)); color: var(--accent); }
.rail-links { display: contents; } 
a.rail-btn { text-decoration: none; }

.panel { width: 300px; min-width: 300px; border-right: 1px solid var(--card-border); }
.panel-scroll {
  height: 100%; overflow-y: auto; padding: 20px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.panel-scroll::-webkit-scrollbar { width: 6px; }
.panel-scroll::-webkit-scrollbar-track { background: transparent; }
.panel-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 4px; }
.panel-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }
.panel-title { display: none; }

.settings-section {
  padding: 12px 14px 14px; margin-bottom: 12px; border-radius: var(--radius-md);
  background: var(--card-bg-soft); border: 1px solid var(--card-border);
  display: flex; flex-direction: column; gap: 12px;
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .settings-section {
    background: linear-gradient(160deg, rgba(255,255,255,0.09), rgba(255,255,255,0.02));
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 10px 30px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.07);
  }
  [data-theme="light"] .settings-section {
    background: linear-gradient(160deg, rgba(255,255,255,0.6), rgba(255,255,255,0.22));
    border: 1px solid rgba(255,255,255,0.65);
    box-shadow: 0 10px 26px rgba(30,40,80,0.10), inset 0 1px 0 rgba(255,255,255,0.55);
  }
  .field, .seg-btn {
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
  }
}
.field-group { display: flex; flex-direction: column; gap: 6px; }
.settings-section .field-label { margin: 0; }
.section-title {
  margin: 0 0 2px; font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--accent);
}

.field-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-dim); margin: 0;
}

.seg-group { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.seg-btn {
  padding: 10px 6px; border-radius: 9px; text-align: center;
  border: 1px solid var(--field-border); background: var(--field-bg);
  color: var(--text-dim); font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: normal; line-height: 1.25; overflow-wrap: break-word;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.seg-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }
[data-theme="light"] .seg-btn:hover { border-color: rgba(20,30,60,0.25); }
.seg-btn:active { transform: scale(0.97); }
.seg-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
}

.swatch-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.swatch {
  aspect-ratio: 1; min-width: 0; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--field-border);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  transition: border-color 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
}
.swatch:hover { transform: scale(1.05); }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,143,247,0.22); }
.swatch.swatch-random { background: var(--field-bg); }
.chip { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.chip-a { background: var(--accent-2); }
.chip-b { background: var(--accent); }
.chip-c { background: var(--accent-teal); }
.chip-d { background: #f59e0b; }
.chip-e { background: #f472b6; }

.field {
  width: 100%; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--field-border); background: var(--field-bg);
  color: var(--text); font-size: 13px; outline: none;
}
.field:focus { border-color: var(--accent); }

select.field { cursor: pointer; }
select.field option {
  background: var(--card-bg);
  color: var(--text);
  padding: 6px;
}
select.field option:checked,
select.field option:hover { background: var(--accent); color: #fff; }
.textarea { resize: vertical; font-family: inherit; }
.char-count { text-align: right; font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.row { display: flex; gap: 8px; }
.row .field { flex: 1; }

.collapsible-toggle {
  width: 100%; display: flex; align-items: center; gap: 8px;
  background: none; border: none; color: var(--text); font-size: 12px; font-weight: 700;
  cursor: pointer; padding: 14px 0 6px; text-transform: uppercase; letter-spacing: 0.4px;
}
.collapsible-toggle.no-pad { padding: 0; text-transform: none; font-size: 13px; }
.chevron { width: 14px; height: 14px; transition: transform 0.15s ease; }
.collapsible-toggle.open .chevron { transform: rotate(180deg); }
.collapsible-panel { padding-top: 4px; }
.link-btn { background: none; border: none; color: var(--text-dim); font-size: 12px; cursor: pointer; }
.link-btn:hover { color: var(--danger); }

.actions { margin-top: 22px; display: flex; flex-direction: column; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--field-border); background: var(--field-bg);
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: rgba(255,255,255,0.08); }
[data-theme="light"] .btn:hover { background: rgba(20,30,60,0.06); }
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; }
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; }
.btn-accent:hover { background: linear-gradient(135deg, var(--accent), var(--accent-2)); filter: brightness(1.12); }
.btn-sm { padding: 8px 12px; font-size: 12px; flex: 1; }
.btn-sm.icon-only { flex: 0 0 auto; padding: 8px 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.content, .right-col { overflow-y: hidden; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.content { flex: 1; min-width: 0; }
.right-col { width: 320px; min-width: 320px; border-left: 1px solid var(--card-border); }

.results-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.results-card .grid { flex: 1; overflow-y: auto; align-content: start; }

.history-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.history-card .history-list { flex: 1; min-height: 0; }

.card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  padding: 16px 18px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-header-title { display: flex; align-items: center; gap: 10px; }
.title-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(79,143,247,0.2), rgba(155,107,255,0.2));
  color: var(--accent); font-size: 15px;
}
.card-header h2 { margin: 0; font-size: 15px; }
.small-title { margin: 0; font-size: 14px; }
.toolbar { display: flex; gap: 6px; align-items: center; }

.log {
  background: rgba(0,0,0,0.22); border: 1px solid var(--card-border); border-radius: 10px;
  padding: 10px 12px; height: 130px; overflow-y: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px;
  color: var(--text-dim); white-space: pre-wrap;
}
[data-theme="light"] .log { background: rgba(20,30,60,0.04); }
.log-small { height: 90px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.res-card {
  aspect-ratio: 1/1;
  border-radius: 10px;
  background: #0a0f1e;
  border: 1px solid var(--field-border);

  position: relative;
  isolation: isolate;
  contain: layout paint;
}
[data-theme="light"] .res-card { background: #f4f6fb; }
.res-thumb {
  position: absolute; inset: 0;
  border-radius: inherit;
  overflow: hidden;
  cursor: pointer;
}
.res-thumb svg, .res-thumb img { display: block; width: 100%; height: 100%; }
.res-thumb .spinner { position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; border: 3px solid var(--field-border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.res-card .status-chip {
  position: absolute; bottom: 5px; left: 5px; font-size: 9px; padding: 2px 7px; border-radius: 999px;
  background: rgba(0,0,0,0.55); color: var(--success); z-index: 2; pointer-events: none;
}
.res-card .status-chip.failed { color: var(--danger); }
.res-card .status-chip.generating { color: var(--accent); }
.res-del {
  position: absolute; top: 5px; right: 5px; z-index: 3;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); color: #fff; border: none; font-size: 11px; line-height: 1; cursor: pointer;
}
.res-del:hover { background: rgba(0,0,0,0.75); }
@keyframes spin { to { transform: rotate(360deg); } }

.history-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.history-empty { padding: 6px 0; }
.history-row { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px; border-radius: 10px; }
.history-row:hover { background: var(--field-bg); }
.history-thumb { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; flex: none; background: #0a0f1e; }
[data-theme="light"] .history-thumb { background: #f4f6fb; }
.history-thumb svg { width: 100%; height: 100%; }
.history-info { min-width: 0; flex: 1; }
.history-info .h-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-info .h-time { font-size: 11px; color: var(--text-dim); }
.history-tag { font-size: 10px; padding: 2px 8px; border-radius: 999px; background: rgba(79,143,247,0.14); color: var(--accent); white-space: nowrap; }
.history-tag.failed { background: rgba(239,68,68,0.14); color: var(--danger); }
.history-tag.generating { background: rgba(79,143,247,0.14); color: var(--accent); }
.history-hint { font-size: 11px; }
.history-modal-list { max-height: 60vh; overflow-y: auto; padding-right: 4px; }

.res-retry {
  position: absolute; right: 6px; bottom: 6px; z-index: 2;
  background: rgba(0,0,0,0.65); color: #fff; border: none; border-radius: 8px;
  font-size: 11px; padding: 5px 9px; cursor: pointer;
}
.res-retry:hover { background: rgba(0,0,0,0.85); }

.modal { position: fixed; inset: 0; background: rgba(4,6,14,0.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card {
  position: relative; width: 420px; max-width: 92vw; max-height: 86vh; overflow-y: auto;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-lg);
  padding: 24px; box-shadow: var(--shadow-card);
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.modal-card::-webkit-scrollbar { width: 5px; }
.modal-card::-webkit-scrollbar-track { background: transparent; }
.modal-card::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 4px; }
.modal-card::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }
.modal-wide { width: 760px; }
.modal-narrow { width: 340px; }
#add-credits-modal .modal-card { width: 480px; }
#add-credits-modal .paymethod-qr { width: 220px; max-width: 220px; margin: 0 auto; max-height: none; }
.modal-close { position: absolute; top: 14px; right: 14px; background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-body-row { display: flex; gap: 20px; }
.detail-preview { flex: 1; min-width: 0; background: #0a0f1e; border-radius: 10px; display: flex; align-items: center; justify-content: center; aspect-ratio: 1/1; }
[data-theme="light"] .detail-preview { background: #f4f6fb; }
.detail-preview svg { width: 100%; height: 100%; }
.detail-side { width: 260px; display: flex; flex-direction: column; gap: 10px; }
.detail-side h3 { margin: 0 0 4px; font-size: 14px; }

.provider-list { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; max-height: 360px; overflow-y: auto; }
.provider-row {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--field-bg); border: 1px solid var(--field-border);
}
.provider-row.active { border-color: var(--accent); }
.provider-row-head { display: flex; align-items: center; gap: 6px; }
.provider-tag { font-size: 10.5px; font-weight: 700; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.provider-active-tag {
  font-size: 9.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: rgba(52, 211, 153, 0.16); color: var(--success);
}
.provider-del {
  margin-left: auto; width: 18px; height: 18px; border-radius: 50%;
  background: none; border: none; color: var(--text-dim); font-size: 11px;
  cursor: pointer; line-height: 1; flex: none;
}
.provider-del:hover { color: var(--danger); }
.provider-row-body { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.provider-row-body .field { padding: 6px 8px; font-size: 12px; }
.provider-row-actions { display: flex; gap: 6px; }
.provider-row-actions .btn { flex: 1; padding: 5px 10px; font-size: 11.5px; }
.add-provider-row { display: flex; gap: 8px; }
.add-provider-row .field { flex: 1; }

.provider-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--field-bg); border: 1px solid var(--field-border);
}
.summary-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-dim); }
.summary-stats b { color: var(--text); font-weight: 700; }
.summary-stats .s-live b { color: var(--success); }
.summary-stats .s-dead b { color: var(--danger); }
.summary-stats .s-limit b { color: #f5b942; }

.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  white-space: nowrap; cursor: default;
}
.status-badge.st-live { background: rgba(52, 211, 153, 0.16); color: var(--success); }
.status-badge.st-dead { background: rgba(248, 113, 113, 0.16); color: var(--danger); }
.status-badge.st-limit { background: rgba(245, 185, 66, 0.16); color: #f5b942; }
.status-badge.st-error { background: rgba(245, 185, 66, 0.16); color: #f5b942; }
.status-badge.st-nokey { background: rgba(148, 163, 184, 0.14); color: var(--text-dim); }
.status-badge.st-legacy { background: rgba(148, 163, 184, 0.14); color: var(--text-dim); }
.status-badge.st-unchecked { background: rgba(148, 163, 184, 0.14); color: var(--text-dim); }
.status-badge.st-checking { background: rgba(79,143,247,0.14); color: var(--accent); }
.provider-check-btn { margin-left: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  max-width: 460px; padding: 11px 18px; border-radius: 12px; font-size: 13px;
  background: var(--card-bg); color: var(--text); border: 1px solid rgba(248,113,113,0.4);
  box-shadow: var(--shadow-card); opacity: 0; pointer-events: none; z-index: 80;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.success { border-color: rgba(52,211,153,0.45); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  .right-col { width: 280px; min-width: 280px; }
}
@media (max-width: 1100px) {
  .tagline { display: none; }
}

@media (max-width: 980px) {
  html, body { height: auto; min-height: 100%; }
  .app-shell { height: auto; min-height: 100vh; }
  .body-row { flex-direction: column; height: auto; overflow: visible; }

  .topbar { flex-wrap: wrap; height: auto; min-height: 64px; padding: 10px 16px; row-gap: 8px; }
  .subtitle { display: none; }
  .topbar-gap { display: none; }

  .rail {
    width: 100%; min-width: 0; flex-direction: row; justify-content: flex-start;
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 8px 10px; gap: 4px; scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail-btn {
    width: auto; flex: none; flex-direction: row; padding: 8px 14px;
    white-space: nowrap;
  }
  .rail-btn span { width: auto; }

  .panel, .content, .right-col {
    width: 100%; min-width: 0; border: none; border-bottom: 1px solid var(--card-border);
    overflow: visible; height: auto;
  }
  .panel-scroll { height: auto; overflow-y: visible; }

  .results-card, .history-card { flex: none; min-height: 0; }
  .results-card .grid, .history-card .history-list { flex: none; overflow-y: visible; max-height: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

  .modal-wide { width: 92vw; }
  .modal-body-row { flex-direction: column; }
  .detail-side { width: 100%; }
  .detail-preview { aspect-ratio: 4/3; }
}

@media (max-width: 640px) {
  body { font-size: 13.5px; }

  .topbar {
    padding: 10px 12px; gap: 8px;
  }
  .brand-block { gap: 8px; }
  .logo, .brand-logo { width: 34px; height: 34px; }
  .brand-block h1 { font-size: 14.5px; }
  .topbar-right { gap: 6px; flex-wrap: wrap; row-gap: 6px; justify-content: flex-end; }

  .icon-btn:not(.icon-btn-credits) { width: 34px; height: 34px; }
  .icon-btn-credits { height: 34px; }
  .icon-btn-credits { padding: 0 10px; font-size: 12px; }

  .notif-panel {
    position: fixed; top: 60px; left: 50%; right: auto; transform: translateX(-50%);
    width: min(92vw, 360px); max-height: calc(100vh - 80px);
  }
  .notif-list { max-height: calc(100vh - 140px); }
  .profile-menu { width: min(92vw, 220px); }
  .notif-detail-banner { padding: 26px 18px 20px; }
  .notif-detail-body { padding: 18px 16px 20px; }

  .settings-section { padding: 12px 12px 14px; gap: 12px; margin-bottom: 12px; }
  .content, .right-col, .panel-scroll { padding: 14px; gap: 14px; }
  .card { padding: 14px; }
  .swatch-grid { gap: 8px; }
  .seg-group { grid-template-columns: repeat(2, 1fr); }

  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .toolbar { flex-wrap: wrap; }

  .modal-card { padding: 16px; max-height: 90vh; }
  .modal-wide { width: 94vw; }
  .provider-row-body { grid-template-columns: 1fr; }
  .add-provider-row { flex-direction: column; }
  .add-provider-row .btn { width: 100%; }

  .toast { width: 92vw; max-width: 360px; left: 50%; }
}

@media (max-width: 420px) {
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; }
  .rail-btn { padding: 7px 10px; font-size: 10.5px; }
  .rail-btn svg { width: 18px; height: 18px; }
  .swatch-grid { grid-template-columns: repeat(4, 1fr); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .count-pill { padding: 0 10px; font-size: 11.5px; }
}

.quick-amount-row { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-amount-row.hidden { display: none; }
.quick-amount-chip {
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--field-border);
  background: transparent; color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.quick-amount-chip:hover { border-color: var(--accent); color: var(--accent); }
.quick-amount-chip.active { border-color: var(--accent); color: var(--accent); background: rgba(79,143,247,0.12); }

.amount-input-wrap { display: flex; align-items: stretch; gap: 8px; }
.amount-input-wrap .field { flex: 1 1 auto; min-width: 0; }
.amount-inline-badge {
  flex: none; display: flex; align-items: center; justify-content: center;
  background: rgba(79,143,247,0.14); color: var(--accent); font-size: 13.5px; font-weight: 800;
  padding: 0 14px; border-radius: 10px; border: 1px solid rgba(79,143,247,0.28);
  white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis;
}
.amount-inline-badge.hidden { display: none; }

.btn-status-icon { display: inline-flex; align-items: center; justify-content: center; margin-right: 6px; }
.btn-status-icon.hidden { display: none; }
.btn-status-icon .spinner {
  width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff; animation: addcredits-spin .7s linear infinite; display: inline-block;
}
@keyframes addcredits-spin { to { transform: rotate(360deg); } }
#addcredits-submit-btn.btn-state-success { background: #1fa855; border-color: #1fa855; }

@keyframes addcredits-check-bounce {
  0% { transform: scale(0.4) rotate(-15deg); opacity: 0; }
  55% { transform: scale(1.25) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
#addcredits-submit-btn.btn-state-success .btn-status-icon { animation: addcredits-check-bounce .45s cubic-bezier(.34,1.56,.64,1); }
#addcredits-submit-btn.btn-state-success { animation: addcredits-pulse-glow 1.1s ease-in-out infinite; }
@keyframes addcredits-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(31,168,85,0.45); }
  50% { box-shadow: 0 0 0 8px rgba(31,168,85,0); }
}
@keyframes addcredits-pop-in {
  0% { opacity: 0; transform: translateY(-6px) scale(0.96); }
  60% { opacity: 1; transform: translateY(0) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.success-text.pop-in { animation: addcredits-pop-in .35s cubic-bezier(.34,1.56,.64,1); }

.addcredits-status { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 30px 16px 26px; text-align: center; }
.addcredits-status.hidden { display: none; }
.addcredits-status-icon {
  width: 78px; height: 78px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(31,168,85,0.14); margin-bottom: 8px;
  animation: addcredits-icon-glow 1.8s ease-in-out .5s infinite;
}
@keyframes addcredits-icon-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(31,168,85,0.35); }
  50% { box-shadow: 0 0 22px 6px rgba(31,168,85,0.35); }
}
.addcredits-status-svg { width: 42px; height: 42px; overflow: visible; }
.addcredits-status-circle {
  stroke: #1fa855; stroke-width: 3; stroke-linecap: round; fill: none;
  stroke-dasharray: 138; stroke-dashoffset: 138;
  animation: addcredits-circle-draw .5s ease-out forwards;
}
.addcredits-status-check {
  stroke: #33d67a; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: addcredits-check-draw .35s ease-out .45s forwards;
}
@keyframes addcredits-circle-draw { to { stroke-dashoffset: 0; } }
@keyframes addcredits-check-draw { to { stroke-dashoffset: 0; } }
.addcredits-status-title { font-size: 20px; font-weight: 800; margin: 4px 0 0; opacity: 0; animation: addcredits-pop-in .3s ease .55s forwards; }
.addcredits-status-sub { font-size: 13px; line-height: 1.5; color: var(--text-dim); max-width: 290px; margin: 0; opacity: 0; animation: addcredits-pop-in .3s ease .65s forwards; }
.addcredits-status-btn {
  margin-top: 16px; width: 100%; border: none; border-radius: 999px; padding: 13px 20px;
  background: #1fa855; color: #fff; font-weight: 800; font-size: 13.5px; letter-spacing: .04em; text-transform: uppercase;
  cursor: pointer; opacity: 0; animation: addcredits-pop-in .3s ease .78s forwards;
}
.addcredits-status-btn:hover { background: #189449; }

#add-credits-modal.status-glow .modal-card {
  border-color: rgba(31,168,85,0.45);
  box-shadow: 0 0 0 1px rgba(31,168,85,0.25), 0 0 34px 6px rgba(31,168,85,0.22), var(--shadow-card);
}
#addcredits-submit-btn.btn-state-error { background: #d64545; border-color: #d64545; }

.paymethod-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.paymethod-chip {
  position: relative; display: inline-flex; flex-direction: row; align-items: center; gap: 7px;
  padding: 6px 12px 6px 6px; border-radius: 999px; border: 1.5px solid var(--field-border); background: var(--field-bg);
  color: var(--text-dim); font-size: 12.5px; font-weight: 700; cursor: pointer; text-align: left;
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s;
}
.paymethod-chip:hover { border-color: rgba(79,143,247,0.5); color: var(--text); }
.paymethod-chip.active {
  border-color: var(--accent); color: var(--accent); background: rgba(79,143,247,0.12);
  box-shadow: 0 0 0 3px rgba(79,143,247,0.14);
}
.paymethod-chip-avatar {
  width: 22px; height: 22px; border-radius: 50%; background: rgba(127,127,127,0.16); flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: var(--text);
}
.paymethod-chip.active .paymethod-chip-avatar { background: var(--accent); color: #fff; }
.paymethod-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.paymethod-chip-check {
  flex: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 9px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.form-section-label { font-size: 11.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-dim); margin: 2px 0 -2px; }
.addcredits-title { display: flex; align-items: center; gap: 10px; }
.addcredits-title::before {
  content: ""; width: 4px; height: 20px; border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), rgba(79,143,247,0.3)); flex: none;
}
.addcredits-title .accent-text { background: linear-gradient(90deg, var(--accent), #a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; }
.paymethod-details { border: 1px solid var(--field-border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.paymethod-qr { width: 100%; aspect-ratio: 1 / 1; max-height: 260px; border-radius: 12px; object-fit: contain; background: #fff; border: 1px solid var(--field-border); display: block; }
.paymethod-info { flex: 1; min-width: 0; }
.paymethod-number-row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.paymethod-number { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; cursor: pointer; border-bottom: 1px dashed currentColor; }
.paymethod-number:hover { color: var(--accent); }
.btn-copy { padding: 4px 10px; font-size: 11px; flex: none; }
.paymethod-note { font-size: 11.5px; color: var(--text-dim); margin: 2px 0 0; text-align: center; }
.paymethod-amount { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: rgba(79,143,247,0.1); border: 1px solid rgba(79,143,247,0.25); font-size: 13px; }
.paymethod-amount b { color: var(--accent); font-size: 15px; }
