:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2330;
  --text-muted: #6b7280;
  --primary: #6d5efc;
  --primary-hover: #5c4de0;
  --primary-soft: #efeeff;
  --danger: #e5484d;
  --success: #16a34a;
  --radius: 14px;
  --shadow: 0 10px 30px -12px rgba(31, 35, 48, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, #efeeff 0%, transparent 45%),
    radial-gradient(circle at 85% 0%, #eaf6ff 0%, transparent 40%),
    var(--bg);
}

a {
  color: var(--primary);
  text-decoration: none;
}

/* ---------- Login page ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  text-align: center;
}

.login-box .logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 1.25rem;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), #9b8cff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.login-box .app-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.login-box .subtitle {
  margin: 0.35rem 0 1.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="file"] {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafafe;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

button {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover {
  background: var(--primary-hover);
}

button:active {
  transform: scale(0.98);
}

.error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

/* ---------- App page ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.topbar .brand .logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #9b8cff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.topbar .logout-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.topbar .logout-link:hover {
  background: #f3f4f6;
  color: var(--text);
}

main.app-main {
  max-width: 720px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.model-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  background: var(--primary-soft);
  border: 1px solid #e0defe;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
}

.model-badge em {
  font-style: normal;
  font-weight: 400;
  color: var(--text-muted);
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone .icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.dropzone .hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.dropzone .filename {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.actions button {
  padding: 0.65rem 1.5rem;
}

.actions button:disabled {
  background: #c9c4ff;
  cursor: not-allowed;
}

#status {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  min-height: 1.2rem;
}

#status.status-success {
  color: var(--success);
}

#status.status-error {
  color: var(--danger);
}

.canvas-wrap {
  display: flex;
  justify-content: center;
}

canvas {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: none;
}

canvas.visible {
  display: block;
}

.settings-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--border);
}

.settings-row[data-age-source-row] {
  border-top: none;
  padding-top: 0;
}

.settings-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.settings-note {
  display: block;
  font-style: normal;
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.settings-hint {
  margin: 0.6rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.settings-hint code {
  background: #f3f4f6;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-size: 0.75rem;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  background: #f9fafb;
}

.segmented button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}

.segmented button.active {
  background: var(--primary);
  color: white;
}

.segmented button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.settings-status {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.spinner {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.pipeline-card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.hardware-line {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hardware-line .tag {
  display: inline-block;
  font-weight: 600;
  color: var(--text);
  background: #f3f4f6;
  border-radius: 6px;
  padding: 0.1rem 0.5rem;
  margin-right: 0.35rem;
}

.pipeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.pipeline-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.85rem;
}

.pipeline-list .step-index {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pipeline-list .step-name {
  flex: 1 1 auto;
  font-weight: 600;
}

.pipeline-list .step-device {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.pipeline-list .step-device.cuda {
  color: #15803d;
  background: #dcfce7;
}

.pipeline-list .step-device.cpu {
  color: #92400e;
  background: #fef3c7;
}

.pipeline-list .step-ms {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.pipeline-list .step-total {
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
  margin-top: 0.1rem;
  font-weight: 700;
}

.pipeline-list .step-total .step-index {
  background: transparent;
}

.param-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.raw-output-card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.raw-face {
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
  font-size: 0.8rem;
}

.raw-face:first-child {
  border-top: none;
  padding-top: 0;
}

.raw-face .raw-face-title {
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.raw-face table {
  width: 100%;
  border-collapse: collapse;
}

.raw-face td {
  padding: 0.2rem 0.5rem 0.2rem 0;
  color: var(--text-muted);
  vertical-align: top;
}

.raw-face td:first-child {
  width: 40%;
  color: var(--text);
  font-weight: 600;
}

.raw-face td.raw-value {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  word-break: break-all;
  color: var(--text);
}
