:root {
  /* --- THEME VARIABLES --- */
  --bg: #1a0033;       /* Deep Purple Background */
  --card: #2a0a4a;     /* Lighter Purple for cards */
  --line: #3a2358;     /* Borders */
  --ink: #f7f7f7;      /* Text Color */
  --muted: #c59fd6;    /* Secondary Text */
  
  --accent: #22c55e;   /* Green (Success/Action) */
  --brand: #ffd94a;    /* Yellow (Headers/Brand) */
  --pink: #ff7ab6;     /* Secondary Accent */
  --blue: #4b8dff;     /* Blue */
  --red: #ef4444;      /* Red (Delete/Clear) */
  
  --input-bg: #0e1520; /* Very dark blue for inputs */
}

/* --- GLOBAL RESETS --- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
  text-align: center;
}

/* --- FORM ELEMENTS (Fixes the ugly white boxes) --- */
input, textarea, select, button {
  font-family: inherit;
  font-size: 14px;
}

/* Target all text inputs to remove the default white background */
input[type="text"],
input[type="number"],
input[type="email"],
textarea {
  width: 100%;
  background: var(--input-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  transition: border-color 0.2s;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 2px rgba(255, 122, 182, 0.2);
}

/* --- MAIN LAYOUT STRUCTURE (.wrap) --- */
.wrap {
  max-width: 1180px;
  margin: 24px auto;
  padding: 0 16px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- HEADER BANNER (.hero) --- */
.hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.hero .title {
  font-weight: 900;
  font-size: 32px;
  color: var(--brand);
  letter-spacing: 1px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.hero .subtitle { color: var(--pink); font-weight: 700; font-size: 18px; }
.hero .subsub { margin-top: 6px; color: var(--muted); font-size: 13px; }

/* --- CARD CONTAINERS (.card) --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  overflow: hidden;
  text-align: left; /* Default to left for controls */
}

/* Header inside card (.hd) */
.card > .hd {
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.card > .hd h2 {
  margin: 0;
  font-size: 15px;
  color: var(--brand);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Body inside card (.bd) */
.card > .bd {
  padding: 20px;
}

/* --- GRID SYSTEM --- */
.stack { display: flex; flex-direction: column; gap: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media(min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.row > * { flex: 1 1 200px; }

/* --- LABELS --- */
label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

/* --- DROPZONE --- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  background: rgba(0,0,0,0.2);
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--ink);
  margin-bottom: 20px;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.05);
  transform: translateY(-2px);
}

.note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* --- BUTTONS --- */
.btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

.btn {
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  font-size: 12px;
  color: #fff;
  transition: filter 0.2s, transform 0.1s;
}

.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); }

/* Specific Button Colors */
.b-blue   { background: var(--blue); color: #fff; }
.b-green  { background: var(--accent); color: #fff; }
.b-accent { background: var(--brand); color: #1a0033; }
.b-red    { background: var(--red); color: #fff; }
.b-pink   { background: var(--pink); color: #1a0033; }

.ghost { 
  background: transparent; 
  border: 1px solid var(--line); 
  color: var(--muted); 
}
.ghost:hover { border-color: var(--ink); color: var(--ink); }

/* --- PREVIEW AREAS --- */
.thumbs { display: grid; grid-template-columns: 1fr; gap: 15px; }

.thumb {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.thumb .meta {
  padding: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wysi .page {
  border: 1px solid var(--line);
  margin-bottom: 10px;
  border-radius: 8px;
  overflow: hidden;
}
.wysi canvas { display: block; width: 100%; height: auto; }

.empty {
  padding: 30px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* --- LOGS --- */
.log {
  font-family: monospace;
  background: rgba(0,0,0,0.3);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--accent);
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
  font-size: 12px;
}

/* --- UTILITIES --- */
.footer {
  margin-top: 30px;
  color: var(--muted);
  font-size: 11px;
  opacity: 0.6;
}