*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --text: #e8eaf0;
  --text-muted: #7c7f93;
  --error: #f04747;
  --warning: #faa61a;
  --success: #43b581;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Layout ── */
.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ── Login page ── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-card .subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* ── Forms ── */
.field { margin-bottom: 1rem; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

input[type="password"],
input[type="url"],
input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

input:focus { border-color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.7rem 1.25rem;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm {
  font-size: 0.85rem;
  padding: 0.45rem 0.9rem;
  width: auto;
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  width: auto;
}

.btn-danger:hover { border-color: var(--error); color: var(--error); background: transparent; }

/* ── Alerts ── */
.alert {
  border-radius: 6px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
}

.alert-error   { background: rgba(240,71,71,0.12);  border: 1px solid rgba(240,71,71,0.3);  color: #f47f7f; }
.alert-warning { background: rgba(250,166,26,0.12); border: 1px solid rgba(250,166,26,0.3); color: var(--warning); }
.alert-info    { background: rgba(88,101,242,0.12); border: 1px solid rgba(88,101,242,0.3); color: #8f9bff; }

/* ── App header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 0.75rem;
}

.app-header h1 { font-size: 1.25rem; font-weight: 700; }
.provider-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(88,101,242,0.18);
  border: 1px solid rgba(88,101,242,0.35);
  color: #8f9bff;
  border-radius: 20px;
  padding: 0.2rem 0.6rem;
}

/* ── URL input row ── */
.input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.input-row input { flex: 1; }
.input-row .btn  { width: auto; padding: 0.65rem 1.1rem; white-space: nowrap; }

/* ── Spinner ── */
.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2.5rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Confirmation dialog ── */
.confirm-card {
  background: var(--surface);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1rem;
  margin-bottom: 1rem;
}

.confirm-card p { font-size: 0.9rem; margin-bottom: 1rem; }

.confirm-actions { display: flex; gap: 0.5rem; }
.confirm-actions .btn { width: auto; }

.countdown {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* ── Results ── */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
}

/* ── Markdown output ── */
.md-output h1 { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.5rem; }
.md-output h2 { font-size: 1rem; font-weight: 700; margin: 1.25rem 0 0.4rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.md-output p  { font-size: 0.95rem; margin-bottom: 0.6rem; }
.md-output ul { padding-left: 1.2rem; margin-bottom: 0.6rem; }
.md-output li { font-size: 0.95rem; margin-bottom: 0.3rem; }
.md-output blockquote { border-left: 3px solid var(--accent); padding-left: 0.75rem; color: var(--text-muted); }

/* ── Utilities ── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }

/* ── Mobile ── */
@media (max-width: 480px) {
  .input-row { flex-direction: column; }
  .input-row .btn { width: 100%; }
  .confirm-actions { flex-direction: column; }
  .confirm-actions .btn { width: 100%; }
}
