:root {
  --bg: #0f1218;
  --panel: #171b24;
  --border: #2a3142;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #5b8def;
  --accent-dim: #3d6bc4;
  --screen-fallback: #ffffff;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.ui-hidden .topbar,
body.ui-hidden .panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

body.ui-hidden .fab-show {
  display: flex;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--screen-fallback);
  transition: background-color 0.15s ease;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(15, 18, 24, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fff 0%, #c8d4e8 100%);
  color: #1a1f2a;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
}

.brand-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.brand-tag {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.panel {
  position: fixed;
  z-index: 2;
  top: 72px;
  right: 1rem;
  width: min(360px, calc(100vw - 2rem));
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.section {
  margin-bottom: 1.1rem;
}

.section:last-of-type {
  margin-bottom: 0;
}

.section h2 {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.swatch {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.swatch:hover {
  transform: scale(1.06);
}

.swatch[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(91, 141, 239, 0.35);
}

.row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.row-tight {
  margin-top: 0.5rem;
}

#colorPicker {
  width: 48px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  background: var(--panel);
}

.hex-input {
  flex: 1;
  min-width: 120px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c0f14;
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
}

.hex-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.slider-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.slider-label input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.size-btn {
  padding: 0.35rem 0.55rem;
  font-size: 0.72rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0c0f14;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.size-btn:hover {
  border-color: var(--muted);
}

.size-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgba(91, 141, 239, 0.15);
}

.num-input {
  width: 5rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c0f14;
  color: var(--text);
  font-size: 0.85rem;
}

.times {
  color: var(--muted);
}

.unit {
  font-size: 0.8rem;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dim);
}

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--muted);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.icon {
  font-size: 1rem;
  line-height: 1;
}

.article {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--muted);
}

.article-heading {
  margin: 0 0 0.6rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.article p {
  margin: 0 0 0.65rem;
}

.article p:last-child {
  margin-bottom: 0;
}

.article strong {
  font-weight: 600;
  color: var(--text);
}

.footer-note {
  margin: 0.75rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.5;
}

.footer-note p {
  margin: 0;
}

kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #0c0f14;
  font-size: 0.68rem;
  font-family: ui-monospace, monospace;
}

.fab-show {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 3;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  align-items: center;
  justify-content: center;
}

.fab-show:hover {
  border-color: var(--accent);
}

@media (max-width: 600px) {
  .panel {
    left: 1rem;
    right: 1rem;
    width: auto;
    top: auto;
    bottom: 1rem;
    max-height: 55vh;
  }

  .btn-fullscreen .btn-text {
    display: none;
  }

  .topbar {
    padding: 0.5rem 0.75rem;
  }
}
