:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #d0d5dd;
  --border-dark: #1a1a2e;
  --text: #000000;
  --text-secondary: #2a2a2a;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eef2ff;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  font-family: "Merriweather", "Georgia", "Playfair Display", "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 2rem;
}

.hdr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--border-dark);
}

.brand { display: flex; gap: 0.75rem; align-items: center; }
.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}
h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.sub {
  margin: 0.15rem 0 0;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 400;
}

.hdr-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.25rem;
}

.auto-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.auto-lbl {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.switch {
  position: relative;
  width: 2.5rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #e2e6ed;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  border: 1px solid #c8ccd6;
}

.switch.is-on {
  background: var(--accent);
  border-color: var(--accent);
}

.switch.is-on::after {
  transform: translateX(1.1rem);
  background: #ffffff;
  border-color: var(--accent);
}

.switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
}

.lbl {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.select-field {
  width: 100%;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fafbfc;
  color: var(--text);
  padding: 0.55rem 0.8rem;
  font-size: 0.92rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.select-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.program-row { margin-top: 0.75rem; }

textarea, input[type="text"] {
  width: 100%;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fafbfc;
  color: var(--text);
  padding: 0.7rem 0.85rem;
  font-size: 0.92rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.15s ease;
}
textarea:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

textarea::placeholder, input::placeholder {
  color: #9ca3af;
}

.opts { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.8rem; }
.opts.hidden { display: none; }

.row { display: flex; flex-direction: column; gap: 0.4rem; }
.lbl-inline { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }

/* Style buttons at top of input panel */
.style-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.style-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1.5px solid var(--border);
  background: var(--panel);
  color: var(--text-secondary);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.18s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.style-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 2px 6px rgba(37,99,235,0.1);
  transform: translateY(-1px);
}
.style-btn.active {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(37,99,235,0.2);
}
.style-btn .s-icon {
  font-size: 0.9rem;
  opacity: 0.8;
}
.style-btn.active .s-icon {
  opacity: 1;
}

.checks { gap: 0.2rem; }
.ck {
  font-size: 0.84rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}
.ck input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}
.btn.primary {
  background: var(--accent);
  color: #ffffff;
}
.btn.primary:hover {
  background: var(--accent-hover);
}
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}
.btn.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn.sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }

.strength-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.hint {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.08rem 0.4rem;
  border-radius: 5px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  font-size: 0.76rem;
  color: var(--accent);
  font-weight: 600;
}

.out-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }

/* Custom style input when Custom button is active */
.custom-style-wrap {
  width: 100%;
  margin-top: 0.5rem;
}
.custom-style-input {
  width: 100%;
  border-radius: 8px;
  border: 1.5px solid var(--accent);
  background: #fafbfc;
  color: var(--text);
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  line-height: 1.4;
  transition: border-color 0.15s ease;
  font-style: italic;
}
.custom-style-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.custom
.custom-style-input::placeholder {
  color: #9ca3af;
  font-style: italic;
}

/* --- Quota display in header ---------------------------------- */
.quota-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  font-size: 0.72rem;
}
.quota-label {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.68rem;
}
.quota-bar-track {
  display: inline-block;
  width: 50px;
  height: 6px;
  border-radius: 3px;
  background: #e2e6ed;
  overflow: hidden;
}
.quota-bar-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: #16a34a;
  transition: width 0.4s ease, background 0.4s ease;
  width: 0%;
}
.quota-text {
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* --- Auth warning banner -------------------------------------- */
.auth-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  font-size: 0.85rem;
  font-weight: 500;
}
.auth-banner .auth-btn {
  border: none;
  background: var(--danger);
  color: #fff;
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}
.auth-banner .auth-btn:hover {
  background: #b91c1c;
}

/* --- Quota exceeded overlay ------------------------------------ */
.quota-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}
.quota-overlay-card {
  background: var(--panel);
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
.quota-overlay-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  color: var(--danger);
}
.quota-overlay-card p {
  margin: 0 0 1.25rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}
.quota-overlay-card .btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.5rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
}
.quota-overlay-card .btn:hover {
  background: var(--accent-hover);
}

/* --- Responsive adjustments for quota display ----------------- */
@media (max-width: 768px) {
  .quota-display {
    order: 10;
    width: 100%;
    justify-content: center;
  }
  .quota-bar-track {
    flex: 1;
    max-width: 80px;
  }
}
