:root {
  --bg: #0f1420;
  --card: #171e2e;
  --border: #262f45;
  --text: #e8ecf5;
  --muted: #93a0b8;
  --accent: #a374ff;
  --accent-2: #34c98f;
  --radius: 14px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fb; --card: #ffffff; --border: #e2e7f0; --text: #16202f;
    --muted: #5b6779; --accent: #7c3aed; --accent-2: #1a9e6b;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.55; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px; }

.site-header { border-bottom: 1px solid var(--border); padding: 18px 0; }
.site-header .wrap { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 0; }
.brand { color: var(--text); font-weight: 700; font-size: 1.2rem; text-decoration: none; }
.brand span { color: var(--accent); }
.site-header nav { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: 0.92rem; }
.site-header nav a:hover { color: var(--text); }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-btn { background: var(--card); color: var(--muted); border: none; padding: 5px 10px; font-size: 0.78rem; font-weight: 600; cursor: pointer; }
.lang-btn.active { background: var(--accent); color: white; }

main.wrap { padding: 40px 20px 60px; }
h1 { font-size: 2rem; margin-bottom: 8px; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }
.lede { color: var(--muted); margin-top: 0; margin-bottom: 32px; max-width: 60ch; }

.calc-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; margin-bottom: 28px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select { width: 100%; padding: 12px 14px; font-size: 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-family: inherit; }
.field textarea { min-height: 90px; resize: vertical; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 180px; }

.option-group { margin-bottom: 20px; }
.option-group > label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 8px; }
.option-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.option-tile { cursor: pointer; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); font-size: 0.88rem; text-align: center; color: var(--text); text-transform: capitalize; }
.option-tile.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; color: var(--accent); font-weight: 600; }

.dropzone {
  border: 2px dashed var(--border); border-radius: 14px; padding: 24px 20px; text-align: center;
  cursor: pointer; color: var(--muted); transition: border-color 0.15s ease;
}
.dropzone.drag { border-color: var(--accent); color: var(--text); }
.dropzone img { max-height: 90px; border-radius: 10px; display: block; margin: 0 auto 10px; }

button.primary { width: 100%; padding: 14px; font-size: 1.05rem; font-weight: 600; border: none; border-radius: 10px; background: var(--accent); color: white; cursor: pointer; }
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.discord-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 10px; background: #5865F2; color: white; text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.discord-btn:hover { filter: brightness(1.1); }

.account { position: relative; }
.account-trigger { display: flex; align-items: center; gap: 7px; padding: 4px 12px 4px 5px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); cursor: pointer; font-size: 0.85rem; color: var(--text); font-family: inherit; }
.account-trigger:hover { border-color: var(--accent); }
.account-trigger img { width: 24px; height: 24px; border-radius: 50%; display: block; }
.admin-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); display: inline-block; }
.account-menu { position: absolute; top: calc(100% + 8px); right: 0; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 6px; min-width: 170px; display: none; flex-direction: column; gap: 2px; box-shadow: 0 10px 30px rgba(0,0,0,0.25); z-index: 30; }
.account-menu.open { display: flex; }
.account-menu a { padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 0.88rem; }
.account-menu a:hover { background: var(--bg); }

.cv-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.cv-row { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.cv-row .meta { color: var(--muted); font-size: 0.82rem; }
.cv-row .actions { display: flex; gap: 8px; }
.cv-row .actions button { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font-size: 0.82rem; }
.cv-row .actions button.danger { color: #e5484d; border-color: rgba(229,72,77,0.3); }

.repeatable-item { border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; position: relative; }
.repeatable-item .remove-item-btn { position: absolute; top: 10px; right: 10px; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; }
.add-item-btn { padding: 9px 14px; border-radius: 8px; border: 1px dashed var(--border); background: none; color: var(--accent); cursor: pointer; font-size: 0.85rem; width: 100%; }

.section-block { margin-bottom: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
.section-block:first-child { padding-top: 0; border-top: none; }
.section-toggle { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; }
.section-toggle .chevron { color: var(--muted); font-size: 0.8rem; transition: transform 0.15s ease; }
.section-block.collapsed .section-toggle .chevron { transform: rotate(-90deg); }
.section-block.collapsed .section-body { display: none; }
.section-block.collapsed h2 { margin-bottom: 0; }

/* The editor needs real width for a side-by-side preview — widen just this page's
   container rather than the whole site, so every other page keeps its narrower,
   easier-to-read column. */
main.wrap:has(.editor-grid) { max-width: 1800px; }
.editor-grid { display: flex; gap: 28px; align-items: flex-start; }
.editor-form-col { flex: 1; min-width: 0; }
/* Native resize handle — starts at 480px, drag the bottom-right corner to
   resize. Flex (not grid) so the form column reflows to fill whatever's left,
   and `resize` works because it's a flex item with an explicit basis rather
   than a grid track (grid columns don't follow a resized child's own box). */
.editor-preview-col {
  position: sticky; top: 20px;
  /* flex-basis must stay `auto` (not a fixed length) so it defers to `width` —
     that's the property the native resize handle actually writes to as you
     drag. A fixed flex-basis would win over width and the handle would look
     draggable but silently do nothing. */
  flex: 0 0 auto; width: 480px; min-width: 320px; max-width: min(1100px, 90vw);
  resize: horizontal; overflow: auto;
}
.preview-pane { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; height: 100%; }
.preview-status { font-size: 0.82rem; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.preview-status.updating::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; animation: preview-pulse 1s ease-in-out infinite; }
@keyframes preview-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
.preview-frame-wrap { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 210 / 297; background: var(--bg); width: 100%; }
.preview-frame-wrap iframe { width: 100%; height: 100%; border: none; display: block; }
.preview-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; color: var(--muted); font-size: 0.88rem; }
.preview-placeholder[hidden] { display: none; }

@media (max-width: 1150px) {
  .editor-grid { flex-direction: column; }
  .editor-preview-col { position: static; resize: vertical; flex-basis: auto; width: 100%; max-width: 100%; height: 70vh; min-height: 320px; }
  .preview-frame-wrap { aspect-ratio: auto; height: 100%; }
}

.site-footer { border-top: 1px solid var(--border); padding: 24px 0 40px; color: var(--muted); font-size: 0.88rem; }
.site-footer .wrap { display: flex; justify-content: space-between; }
.site-footer a { color: var(--muted); }

.notice-box { background: rgba(163,116,255,0.1); border: 1px solid rgba(163,116,255,0.3); color: var(--text); padding: 12px 16px; border-radius: 10px; font-size: 0.88rem; margin-bottom: 20px; }
.save-btn { padding: 8px 14px; border-radius: 8px; border: none; background: var(--accent); color: white; cursor: pointer; font-size: 0.85rem; }

@media (max-width: 600px) {
  main.wrap { padding: 24px 16px 48px; }
  .calc-card { padding: 18px; }
}
