:root {
  --bg: #07090a;
  --bg-panel: #121712;
  --bg-panel-raised: #171d17;
  --border: #2c3a26;
  --border-soft: #1a231a;
  --green: #3fe066;
  --green-dim: #1f9e40;
  --green-glow: rgba(63, 224, 102, 0.35);
  --text: #eaf5ea;
  --text-dim: #a2b6a3;
  --text-faint: #647466;
  --danger: #ff5c45;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Oswald', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
}

#space {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.grain {
  position: fixed;
  inset: -200px;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(3, 4, 3, 0.6) 100%);
}

/* Profile / link-in-bio page */

.profile {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 60px 24px;
  z-index: 2;
}

.avatar {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  box-shadow: 0 0 0 6px rgba(63, 224, 102, 0.06), 0 12px 40px rgba(0, 0, 0, 0.5);
}

.profile-name {
  margin: 0;
  font-weight: 600;
  font-size: 26px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}

.link-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(360px, 88vw);
  margin-top: 8px;
}

.link-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.link-btn:hover {
  border-color: var(--brand, var(--green));
  background: var(--bg-panel-raised);
  transform: translateY(-2px);
}

.link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--brand, var(--green));
  flex-shrink: 0;
}

.link-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.link-name {
  text-transform: uppercase;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #ff5c45;
  border: 1px solid rgba(255, 92, 69, 0.4);
  border-radius: 20px;
  flex-shrink: 0;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff5c45;
  animation: live-pulse 1.4s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Gate / unlock panel */

.panel,
.unlock-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 36px 42px;
  width: min(340px, 86vw);
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.panel:focus-within,
.unlock-panel:focus-within {
  border-color: var(--green-dim);
}

#password,
#unlock-password {
  width: 100%;
  text-align: center;
  padding: 10px 4px;
  font-family: inherit;
  font-size: 17px;
  letter-spacing: 0.28em;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
  transition: border-color 0.25s ease;
}

#password::placeholder,
#unlock-password::placeholder {
  letter-spacing: normal;
  color: var(--text-faint);
}

#password:focus,
#unlock-password:focus {
  border-color: var(--green);
}

.panel button,
.unlock-panel button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s ease, gap 0.2s ease;
}

.panel button:hover,
.unlock-panel button:hover {
  color: var(--green);
  gap: 10px;
}

.panel button:active,
.unlock-panel button:active {
  transform: scale(0.98);
}

.gate-message {
  height: 12px;
  margin: -4px 0 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--danger);
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.gate-message.show {
  opacity: 1;
}

.gate-message.granted {
  color: var(--green);
}

.panel.shake,
.unlock-panel.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* 404 */

.notfound {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 2;
}

.notfound-image {
  width: min(260px, 60vw);
  height: auto;
  margin-bottom: 4px;
  filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.5));
}

.notfound-message {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--text-dim);
}

.notfound-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s ease, gap 0.2s ease;
}

.notfound-link:hover {
  color: var(--green);
  gap: 10px;
}

/* Dashboard */

.back-link {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s ease, gap 0.2s ease;
}

.back-link:hover {
  color: var(--green);
  gap: 10px;
}

.page-tabs {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  padding: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.page-tab {
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s ease, background 0.2s ease;
}

.page-tab:hover {
  color: var(--text);
}

.page-tab.is-active {
  color: #04150a;
  background: var(--green);
}

.dashboard {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 96px 24px 60px;
}

.dashboard-header {
  width: min(880px, 100%);
  margin-bottom: 48px;
}

.dashboard-title {
  margin: 0;
  font-weight: 600;
  font-size: 28px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}

.dashboard-sub {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  width: min(880px, 100%);
}

.project-card {
  --accent: 63, 224, 102;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 12px;
  padding: 24px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.15s ease;
}

.project-card:hover {
  border-color: rgba(var(--accent), 0.55);
  background: var(--bg-panel-raised);
  transform: translateY(-2px);
}

.project-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 18px;
  border-radius: 10px;
  background: rgba(var(--accent), 0.14);
}

.project-icon.has-image {
  width: auto;
  padding: 0 12px;
}

.project-icon img {
  display: block;
  height: 30px;
  width: auto;
}

.project-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.project-tagline {
  margin-top: -6px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.55;
}

.click-stats {
  width: min(880px, 100%);
  margin-top: 40px;
}

.click-stats-title {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.click-stats-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.click-stats-list span {
  padding: 8px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.click-stats-list strong {
  color: var(--green);
  margin-left: 6px;
}

.project-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}

/* Chat page */

.chatpage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 96px 24px 24px;
}

.chatpage-header {
  width: min(720px, 100%);
  margin-bottom: 20px;
  flex-shrink: 0;
}

.chatpage-popout {
  padding: 14px 14px 10px;
}

.chat-toolbar-popout {
  justify-content: flex-end;
}

/* Stream stats */

.chat-stats-live {
  display: none;
  margin-left: 2px;
  padding: 1px 6px;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--danger);
  border: 1px solid rgba(255, 92, 69, 0.45);
  border-radius: 10px;
}

.chat-stats-btn.is-live .chat-stats-live {
  display: inline;
}

.modal-panel.stats-panel {
  width: min(760px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  gap: 14px;
}

.stats-back {
  padding: 0;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green);
  cursor: pointer;
}

.stats-body,
.stats-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.stats-history[hidden] {
  display: none;
}

.stats-subtitle {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.stats-stream-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.stats-when,
.stats-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

.stats-note {
  color: var(--danger);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  width: 100%;
}

.stats-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.stats-tile-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stats-tile-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--green);
}

.stats-tile-note {
  font-size: 11.5px;
  color: var(--text-faint);
}

.stats-chart {
  width: 100%;
  height: 120px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.stats-chart-area {
  fill: rgba(63, 224, 102, 0.12);
}

.stats-chart-line {
  fill: none;
  stroke: var(--green);
  stroke-width: 2;
}

.stats-line-kick { stroke: #53fc18; stroke-width: 1.5; opacity: 0.7; stroke-dasharray: 4 3; }
.stats-line-twitch { stroke: #9146ff; stroke-width: 1.5; opacity: 0.85; }

.stats-viewers {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
}

.stats-viewers th,
.stats-viewers td {
  padding: 9px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
}

.stats-viewers thead th {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stats-viewers th:first-child { text-align: left; }
.stats-viewers tbody tr:last-child > * { border-bottom: 0; }
.stats-viewers tbody td { font-weight: 600; }
.stats-viewers tbody tr:first-child td { color: var(--green); }

.stats-legend {
  display: flex;
  gap: 16px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.stats-key-all::before,
.stats-key-kick::before,
.stats-key-twitch::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--green);
}

.stats-key-kick::before { background: #53fc18; }
.stats-key-twitch::before { background: #9146ff; }

.stats-chart-axis {
  display: flex;
  justify-content: space-between;
  margin-top: -6px;
  font-size: 11px;
  color: var(--text-faint);
}

.stats-chart-empty,
.stats-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--text-faint);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.stats-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.stats-platforms b {
  color: var(--text);
}

.stats-history-row {
  display: grid;
  grid-template-columns: minmax(140px, 2fr) repeat(4, minmax(60px, 1fr));
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.stats-history-row:hover {
  border-color: var(--green-dim);
}

.stats-history-when {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text);
}

.stats-history-when em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .stats-history-row {
    grid-template-columns: 1fr 1fr;
  }

  .stats-history-when {
    grid-column: 1 / -1;
  }
}

/* OBS overlay: ?transparent=1 on the popout page */
html.overlay-transparent,
html.overlay-transparent body {
  background: transparent;
}

html.overlay-transparent #space,
html.overlay-transparent .grain,
html.overlay-transparent .vignette,
html.overlay-transparent .chat-toolbar,
html.overlay-transparent .chat-banner {
  display: none;
}

html.overlay-transparent .chatpage {
  padding: 0;
}

html.overlay-transparent .chat-feed {
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: hidden;
  justify-content: flex-end;
}

html.overlay-transparent .chat-content {
  color: #fff;
}

html.overlay-transparent .chat-row {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 2px rgba(0, 0, 0, 0.9);
}

.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(720px, 100%);
  margin-bottom: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.chat-connections {
  display: flex;
  gap: 12px;
}

.chat-connections[hidden] {
  display: none;
}

.chat-toolbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.chat-popout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.chat-popout-btn:hover {
  color: var(--green);
  border-color: var(--green-dim);
}

.chat-size-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-size-label {
  color: var(--text-faint);
  line-height: 1;
}

.chat-size-label-sm { font-size: 11px; }
.chat-size-label-lg { font-size: 16px; }

#chat-size {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

#chat-size::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(63, 224, 102, 0.2);
  cursor: pointer;
}

#chat-size::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(63, 224, 102, 0.2);
  cursor: pointer;
}

#chat-size::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.chat-connection {
  display: flex;
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  transition: border-color 0.2s ease;
}

.chat-connection:has(.chat-connection-link):hover {
  border-color: var(--green-dim);
}

.chat-connection > a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  text-decoration: none;
}

.chat-connection > a:not(.chat-connection-link) {
  width: 100%;
  color: var(--green);
}

.chat-connection > a:not(.chat-connection-link):hover {
  text-decoration: underline;
}

.chat-connection-disconnect {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-faint);
  background: transparent;
  border: none;
  border-left: 1px solid var(--border-soft);
  cursor: pointer;
  flex-shrink: 0;
}

.chat-connection-disconnect:hover {
  color: var(--danger);
}

.chat-connection-link {
  color: inherit;
}

.chat-connection-link:hover {
  color: var(--green);
}

.chat-connection-icon {
  display: flex;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}

.chat-connection-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.chat-connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  margin-left: 4px;
}

.chat-connection-viewers {
  font-size: 11px;
  color: var(--text-faint);
  padding-left: 8px;
  border-left: 1px solid var(--border-soft);
}

.chat-banner {
  width: min(720px, 100%);
  margin: 0 0 12px;
  padding: 0;
  font-size: 12.5px;
  color: var(--green);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.chat-banner.show {
  max-height: 40px;
  opacity: 1;
}

.chat-banner.error {
  color: var(--danger);
}

.chat-feed {
  width: min(720px, 100%);
  flex: 1;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--chat-font-size, 13.5px);
  line-height: 1.5;
  flex-wrap: wrap;
}

.chat-platform-icon {
  display: inline-flex;
  width: 0.95em;
  height: 0.95em;
  flex-shrink: 0;
  align-self: center;
}

.chat-platform-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.chat-platform-kick { color: #53fc18; }
.chat-platform-twitch { color: #9146ff; }

.chat-username {
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.chat-username:hover {
  text-decoration: underline;
}

.chat-content {
  color: var(--text-dim);
  word-break: break-word;
}

.chat-emote {
  height: 1.6em;
  width: auto;
  vertical-align: middle;
  margin: -0.3em 1px;
}

.mod-menu {
  position: fixed;
  z-index: 20;
  display: none;
  flex-direction: column;
  min-width: 160px;
  background: var(--bg-panel-raised);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.mod-menu.open {
  display: flex;
}

.mod-menu button {
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.mod-menu button:last-child {
  border-bottom: none;
  color: var(--danger);
}

.mod-menu button:hover {
  background: var(--bg-panel);
}

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 4, 3, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-panel {
  --accent: 63, 224, 102;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  width: min(360px, 86vw);
  padding: 40px 34px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  transform: translateY(10px) scale(0.98);
  transition: transform 0.25s ease;
}

.unlock-panel {
  align-items: center;
}

#unlock-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.modal-overlay.open .modal-panel {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
}

.modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  font-size: 20px;
  border-radius: 12px;
  background: rgba(var(--accent), 0.16);
}

.modal-icon.has-image {
  width: auto;
  padding: 0 16px;
}

.modal-icon img {
  display: block;
  height: 32px;
  width: auto;
}

.modal-title {
  margin: 0;
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
}

.modal-tagline {
  margin: -6px 0 6px;
  font-size: 13px;
  text-align: left;
  color: var(--text-dim);
  line-height: 1.55;
}

.modal-links {
  display: flex;
  gap: 10px;
  width: 100%;
}

.modal-link {
  flex: 1;
  text-align: center;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.modal-link:hover {
  border-color: var(--text-dim);
  background: var(--bg-panel-raised);
}

.modal-link.primary {
  background: rgba(var(--accent), 0.9);
  border-color: rgba(var(--accent), 0.9);
  color: #04150a;
}

.modal-link.primary:hover {
  background: rgb(var(--accent));
  border-color: rgb(var(--accent));
}

/* Finance page */

.financepage {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 96px 24px 60px;
}

.financepage-header {
  width: min(720px, 100%);
  margin-bottom: 20px;
}

.finance-summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: min(720px, 100%);
  margin-bottom: 20px;
  padding: 18px 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}

.finance-summary-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.finance-summary-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--green);
}

.finance-toolbar {
  display: flex;
  justify-content: flex-end;
  width: min(720px, 100%);
  margin-bottom: 14px;
}

.finance-add-btn {
  padding: 10px 16px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #04150a;
  background: var(--green);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.finance-add-btn:hover {
  background: #57ea78;
  transform: translateY(-1px);
}

.finance-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(720px, 100%);
}

.finance-empty {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}

.finance-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.finance-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.finance-row-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.finance-row-day {
  font-size: 11.5px;
  color: var(--text-faint);
}

.finance-row-amount {
  font-size: 15px;
  font-weight: 600;
  color: var(--green);
  flex-shrink: 0;
  white-space: nowrap;
}

.finance-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.finance-row-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 13px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.finance-row-actions button:hover {
  color: var(--green);
  border-color: var(--green-dim);
}

.finance-row-actions .finance-delete:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.finance-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.finance-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.finance-field input {
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s ease;
}

.finance-field input:focus {
  border-color: var(--green-dim);
}

.finance-form-error {
  margin: -6px 0 0;
  font-size: 11px;
  color: var(--danger);
  min-height: 12px;
}

/* Storage page */

.storagepage {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 96px 24px 60px;
}

.storagepage-header {
  width: min(880px, 100%);
  margin-bottom: 20px;
}

.storage-notice {
  width: min(880px, 100%);
  margin: 0 0 12px;
  padding: 0;
  font-size: 12.5px;
  color: var(--green);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.storage-notice.show {
  max-height: 60px;
  opacity: 1;
  padding: 10px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}

.storage-notice.error {
  color: var(--danger);
}

.storage-usage {
  width: min(880px, 100%);
  margin-bottom: 18px;
  padding: 16px 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}

.storage-usage-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--border-soft);
  overflow: hidden;
  margin-bottom: 10px;
}

.storage-usage-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.3s ease;
}

.storage-usage-fill-warn {
  background: var(--danger);
}

.storage-usage-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

#storage-usage-count {
  color: var(--text-faint);
  flex-shrink: 0;
}

.storage-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: min(880px, 100%);
  margin-bottom: 14px;
}

.storage-search {
  flex: 1;
  min-width: 160px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  outline: none;
}

.storage-search:focus {
  border-color: var(--green-dim);
}

.storage-sort {
  padding: 10px 12px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  outline: none;
}

.storage-secondary-btn {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
}

.storage-secondary-btn:hover {
  background: var(--bg-panel-raised);
  transform: none;
}

.storage-folder-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: min(880px, 100%);
  margin-bottom: 16px;
}

.storage-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  cursor: pointer;
}

.storage-chip-sep {
  color: var(--text-faint);
  font-size: 13px;
}

.storage-chip-current {
  cursor: default;
}

.storage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(880px, 100%);
}

.storage-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.storage-row-folder {
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.storage-row-folder:hover {
  border-color: var(--green-dim);
  background: var(--bg-panel-raised);
}

.storage-row-folder .storage-thumb {
  color: var(--green);
}

.storage-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--bg-panel-raised);
  color: var(--text-dim);
  overflow: hidden;
}

.storage-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.storage-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.storage-row-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storage-row-meta {
  font-size: 11.5px;
  color: var(--text-faint);
}

.storage-row-desc {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storage-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.storage-row-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 13px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.storage-row-actions button:hover {
  color: var(--green);
  border-color: var(--green-dim);
}

.storage-row-actions .finance-delete:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.storage-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--green);
  background: rgba(3, 4, 3, 0.85);
  border: 3px dashed var(--green-dim);
}

.storage-drop-overlay.show {
  display: flex;
}

.storage-preview-panel {
  width: min(720px, 92vw);
}

.storage-preview-body {
  width: 100%;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.storage-preview-image {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
}

.storage-preview-frame {
  width: 100%;
  height: 70vh;
  border: none;
  border-radius: 8px;
}

/* Home dashboard */

.dashpage {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 96px 24px 60px;
}

.dashpage .dashboard-header {
  width: min(1500px, 100%);
}

.dashpage .dashboard-title {
  font-size: 36px;
}

.dashpage .dashboard-sub {
  font-size: 14.5px;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
  width: min(1500px, 100%);
}

.dash-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 30px;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
}

.dash-card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.dash-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 15px;
  color: var(--text);
  flex: 1;
}

.dash-card-link {
  align-self: flex-start;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--green);
  text-decoration: none;
}

.dash-card-link:hover {
  text-decoration: underline;
}

.dash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dash-row-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
}

.dash-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.dash-dot.is-on {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(63, 224, 102, 0.15);
}

.dash-dot.is-live {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 92, 69, 0.18);
}

.dash-when {
  min-width: 78px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.dash-when.is-soon {
  color: var(--green);
  font-weight: 600;
}

.dash-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.dash-warn {
  font-size: 13px;
  color: var(--danger);
}

.dash-muted {
  font-size: 13px;
  color: var(--text-faint);
}

.dash-usage-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--border-soft);
  overflow: hidden;
}

.dash-usage-fill {
  height: 100%;
  background: var(--green);
}

@media (max-width: 640px) {
  .back-link {
    top: 14px;
    left: 14px;
  }

  .page-tabs {
    top: 58px;
    left: 14px;
    right: 14px;
    justify-content: center;
  }

  .dashboard,
  .dashpage,
  .chatpage,
  .financepage,
  .storagepage {
    padding-top: 156px;
  }

  .chatpage-popout {
    padding-top: 14px;
  }

  .storage-row {
    flex-wrap: wrap;
  }

  .storage-row-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
