/* Portal design system: dark canvas, violet accents, one set of tokens
   shared by the login screen, the desktop and every application. */

:root {
  --bg: #0c0916;
  --bg-deep: #07050e;
  --surface: #161127;
  --surface-2: #1e1733;
  --surface-3: #271e42;
  --border: #2f2550;
  --border-soft: #241d3d;

  --text: #ece8fa;
  --text-dim: #b6adda;
  --text-faint: #7d74a0;

  --accent: #a855f7;
  --accent-bright: #c084fc;
  --accent-deep: #7c3aed;
  --accent-soft: rgba(168, 85, 247, 0.16);
  --accent-line: rgba(168, 85, 247, 0.38);

  --danger: #fb5a7d;
  --danger-soft: rgba(251, 90, 125, 0.14);
  --ok: #4ade80;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  --shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.3);

  --font: "Segoe UI", system-ui, -apple-system, "Inter", "Helvetica Neue", Arial, sans-serif;

  color-scheme: dark;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-bright); text-decoration: none; }

/* Ambient violet glow used as the page backdrop. */
.login-glow,
.desktop-glow,
.app-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60rem 34rem at 12% -8%, rgba(124, 58, 237, 0.30), transparent 62%),
    radial-gradient(48rem 30rem at 92% 4%, rgba(168, 85, 247, 0.18), transparent 60%),
    radial-gradient(52rem 40rem at 50% 118%, rgba(88, 28, 135, 0.28), transparent 66%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease, color 0.16s ease;
}

.btn:hover { background: var(--surface-3); border-color: var(--accent-line); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 26px rgba(124, 58, 237, 0.34);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #8b46f0, var(--accent-bright));
  border-color: transparent;
}

.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--danger-soft); border-color: rgba(251, 90, 125, 0.4); color: var(--danger); }
.btn-danger:hover { background: rgba(251, 90, 125, 0.24); border-color: var(--danger); }

.btn-small { padding: 7px 13px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }

/* Small square icon button, used for delete/edit affordances. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--text); background: var(--surface-3); border-color: var(--border); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); border-color: rgba(251, 90, 125, 0.4); }

/* ---------- form controls ---------- */

.field { display: block; }
.field + .field { margin-top: 14px; }

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(8, 6, 16, 0.6);
  color: var(--text);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.input::placeholder { color: var(--text-faint); }
.input:focus {
  border-color: var(--accent);
  background: rgba(8, 6, 16, 0.85);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

/* ---------- application shell ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px clamp(16px, 4vw, 34px);
  background: rgba(12, 9, 22, 0.82);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(14px);
}

.app-title {
  font-size: 17px;
  font-weight: 650;
  text-align: center;
  letter-spacing: 0.01em;
}

.app-header-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  justify-self: end;
  min-width: 84px;
}

.app-actions { display: flex; align-items: center; gap: 6px; }

.app-status { font-size: 12px; color: var(--text-faint); }
.app-status.saving { color: var(--accent-bright); }
.app-status.saved { color: var(--ok); }
.app-status.failed { color: var(--danger); }

.home-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.home-btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.home-btn:hover { color: var(--text); background: var(--surface-3); border-color: var(--accent-line); }

/* On a sub-page the same control steps back instead of leaving the app. */
.home-btn.is-back { color: var(--accent-bright); border-color: var(--accent-line); }
.home-btn.is-back:hover { background: var(--accent-soft); }

.app-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(18px, 4vw, 34px) clamp(16px, 4vw, 34px) 80px;
}

.app-view[hidden] { display: none; }

.section-title {
  margin-bottom: 14px;
  font-size: 15px;
  font-weight: 650;
  color: var(--text-dim);
}

.empty-note {
  padding: 34px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-faint);
  text-align: center;
}

.card-surface {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface), rgba(18, 13, 32, 0.85));
  box-shadow: var(--shadow-soft);
}

/* ---------- modals ---------- */

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 3, 12, 0.72);
  backdrop-filter: blur(6px);
  animation: fade-in 0.14s ease;
}
.modal-layer[hidden] { display: none; }

.modal {
  width: min(460px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow);
  animation: rise 0.18s ease;
}
.modal.modal-wide { width: min(680px, 100%); }

.modal-title { margin-bottom: 4px; font-size: 18px; font-weight: 650; }
.modal-text { margin-bottom: 16px; color: var(--text-dim); font-size: 14px; }
.modal-body { margin-bottom: 18px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- toasts ---------- */

.toast-layer {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow-soft);
  animation: rise 0.18s ease;
}
.toast.error { border-color: rgba(251, 90, 125, 0.45); color: #ffd7e0; background: #3a1526; }

/* ---------- scrollbars ---------- */

* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border: 3px solid transparent; background-clip: content-box; border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--border); background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
