@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,300&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #060812;
  --surface: #0d1117;
  --surface2: #111827;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(139,92,246,0.4);
  --accent: #7c3aed;
  --accent2: #06b6d4;
  --text: #f1f5f9;
  --muted: #64748b;
  --success: #10b981;
  --danger: #f43f5e;
}

body {
  font-family: 'DM Sans', sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(124,58,237,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(6,182,212,0.08) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.015'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
}

/* ===== LOGIN ===== */
#login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(124,58,237,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(6,182,212,0.08) 0%, transparent 60%);
  z-index: 100;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  overflow: hidden;
}

.login-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124,58,237,0.6), rgba(6,182,212,0.4), transparent);
}

.login-box input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.4);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
  display: block;
  margin-bottom: 4px;
}

.login-box input::placeholder { color: #374151; }
.login-box input:focus {
  border-color: rgba(124,58,237,0.5);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.08);
}

.login-error { color: var(--danger); font-size: 12px; margin-top: 10px; min-height: 18px; }

/* ===== LOADING PAGE ===== */
#loading-page {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(124,58,237,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(6,182,212,0.08) 0%, transparent 60%);
  z-index: 99;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 340px;
}

.loading-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.loading-bar-wrap {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 100px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  width: 0%;
  border-radius: 100px;
  background: linear-gradient(90deg, #7c3aed, #06b6d4);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-status {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  min-height: 18px;
}

/* ===== THREE COLUMN LAYOUT ===== */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr 1fr;
  gap: 16px;
  width: 100%;
  max-width: 1400px;
  align-items: start;
}

/* ===== LEFT TOOLS COL ===== */
.tools-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tools-header { padding: 0 4px; margin-bottom: 4px; }

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(6,182,212,0.5), transparent);
}

.tool-card:hover { border-color: rgba(6,182,212,0.25); }

.tool-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.tool-icon { font-size: 15px; }

.tool-title {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.tool-desc {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

.tool-card input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.4);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.25s;
}

.tool-card input[type="text"]::placeholder { color: #374151; }
.tool-card input[type="text"]:focus { border-color: rgba(6,182,212,0.4); }

.tool-btn {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(6,182,212,0.25);
  border-radius: 10px;
  background: rgba(6,182,212,0.1);
  color: var(--accent2);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 10px;
  transition: background 0.2s, transform 0.2s;
}

.tool-btn:hover { background: rgba(6,182,212,0.2); transform: translateY(-1px); }

.quick-brands { display: flex; flex-wrap: wrap; gap: 5px; }

.brand-tag {
  padding: 3px 8px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
  width: auto;
}

.brand-tag:hover, .brand-tag.active {
  border-color: rgba(6,182,212,0.4);
  color: var(--accent2);
  background: rgba(6,182,212,0.08);
}

/* ===== DROPZONE ===== */
.dropzone {
  border: 1.5px dashed rgba(6,182,212,0.3);
  border-radius: 12px;
  padding: 20px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: rgba(6,182,212,0.03);
  margin-bottom: 8px;
}

.dropzone:hover, .dropzone.drag-over {
  border-color: rgba(6,182,212,0.6);
  background: rgba(6,182,212,0.07);
}

.drop-icon { font-size: 22px; }
.drop-text { font-size: 11px; color: var(--muted); text-align: center; }

/* ===== SPLIT PREVIEW ===== */
.preview-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 6px;
}

.preview-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.preview-item canvas {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.download-half-btn {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(6,182,212,0.25);
  border-radius: 8px;
  background: rgba(6,182,212,0.08);
  color: var(--accent2);
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.download-half-btn:hover { background: rgba(6,182,212,0.18); }

/* ===== MIDDLE ===== */
.left {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px 28px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s;
}

.left::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124,58,237,0.6), rgba(6,182,212,0.4), transparent);
}

.left:hover { border-color: var(--border-hover); }

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(124,58,237,0.12);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 500;
  color: #a78bfa;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #7c3aed;
  box-shadow: 0 0 6px #7c3aed;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px #7c3aed; }
  50% { opacity: 0.5; box-shadow: 0 0 12px #7c3aed; }
}

h2 {
  font-family: 'Syne', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 24px;
  font-weight: 300;
}

.field-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: block;
}

textarea {
  width: 100%;
  height: 160px;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 14px;
  background: rgba(0,0,0,0.4);
  color: var(--text);
  outline: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  line-height: 1.7;
  resize: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

textarea::placeholder { color: #374151; font-style: italic; }
textarea:focus {
  border-color: rgba(124,58,237,0.5);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.08);
}

.char-count {
  text-align: right;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  margin-bottom: 14px;
}

button#btn, button#login-btn {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 50%, #0e7490 100%);
  color: white;
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

button#btn:hover, button#login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(124,58,237,0.4);
}

button#btn:active, button#login-btn:active { transform: translateY(0); }
button#btn.loading { pointer-events: none; opacity: 0.8; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.2s, color 0.2s;
  width: auto;
}

.ghost-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ===== HISTORY ===== */
.history-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.no-history {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 16px 0;
  font-style: italic;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  background: rgba(255,255,255,0.02);
}

.history-item:hover { background: rgba(124,58,237,0.08); border-color: rgba(124,58,237,0.25); }
.history-item.active { background: rgba(124,58,237,0.12); border-color: rgba(124,58,237,0.4); }

.history-time { font-size: 10px; color: var(--accent2); white-space: nowrap; font-weight: 500; }
.history-preview { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== RIGHT ===== */
#result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px 24px 24px 28px;
  border-left: 3px solid var(--accent);
  min-height: 500px;
  max-height: 700px;
  overflow-y: auto;
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.9;
  transition: border-color 0.3s;
}

#result:hover { border-left-color: var(--accent2); }

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.result-title {
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.export-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
  width: auto;
}

.icon-btn:hover { background: rgba(124,58,237,0.12); border-color: rgba(124,58,246,0.3); color: #a78bfa; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 500;
  background: rgba(100,116,139,0.15);
  color: var(--muted);
  border: 1px solid rgba(100,116,139,0.2);
}

.status-pill.active {
  background: rgba(16,185,129,0.1);
  color: var(--success);
  border-color: rgba(16,185,129,0.25);
}

.status-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

#result-content { min-height: 300px; }

.waiting-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 16px;
}

.waiting-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.waiting-text { font-size: 13px; color: var(--muted); font-style: italic; }

.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.high-risk { color: var(--danger); font-weight: 500; }
.low-risk { color: var(--success); font-weight: 500; }

#result::-webkit-scrollbar { width: 4px; }
#result::-webkit-scrollbar-track { background: transparent; }
#result::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
#result::-webkit-scrollbar-thumb:hover { background: rgba(124,58,237,0.4); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  body { padding: 20px 16px; }
}