/* CosmixApp dashboard — single stylesheet, no dependencies. */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7fb;
  --ink: #0f172a;
  --ink-soft: #475569;
  --accent: #4f46e5;
  --accent-strong: #4338c2;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3 {
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.75rem;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--ink-soft);
}

.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn-secondary {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--bg-soft);
}

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

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #ffffff;
}

.btn-block {
  width: 100%;
}

/* ---------------- forms ---------------- */

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.35rem;
}

.field input,
.field select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field .hint {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}

.field-error {
  display: block;
  font-size: 0.85rem;
  color: var(--danger);
  margin-top: 0.3rem;
  min-height: 1.1em;
}

/* ---------------- alerts ---------------- */

.alert {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.95rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.alert-error {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: #991b1b;
}

.alert-success {
  background: var(--ok-soft);
  border-color: #bbf7d0;
  color: #166534;
}

.alert-info {
  background: var(--accent-soft);
  border-color: #dfe3ff;
  color: #3730a3;
}

/* ---------------- auth screens ---------------- */

.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 100%);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

.auth-brand .logo {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.55rem;
  display: block;
}

.auth-card {
  width: min(26rem, 100%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.auth-card h1 {
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

.auth-sub {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.auth-switch {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.auth-switch a {
  font-weight: 600;
}

.auth-back {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.9rem;
}

/* ---------------- app shell ---------------- */

.shell {
  display: grid;
  grid-template-columns: 16.5rem minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
  padding: 0.4rem 0.6rem;
  margin-bottom: 1rem;
}

.sidebar-brand .logo {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 0.5rem;
  display: block;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.nav-link:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.nav-link svg {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: 99px;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
}

.avatar {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.user-meta {
  min-width: 0;
}

.user-name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-mail {
  font-size: 0.8rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  margin-top: 0.6rem;
  width: 100%;
}

.verified-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid #bbf7d0;
  border-radius: 99px;
  padding: 0.05rem 0.5rem;
  margin-top: 0.35rem;
}

.unverified-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid #fde68a;
  border-radius: 99px;
  padding: 0.05rem 0.5rem;
  margin-top: 0.35rem;
}

/* ---------------- main column ---------------- */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.content {
  padding: 1.75rem;
  max-width: 64rem;
  width: 100%;
}

.view-head {
  margin-bottom: 1.5rem;
}

.view-head h2 {
  font-size: 1.45rem;
  margin-bottom: 0.25rem;
}

.view-head p {
  color: var(--ink-soft);
  margin: 0;
}

/* ---------------- panels + placeholders ---------------- */

.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.panel h3 {
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
}

.placeholder-panel {
  text-align: center;
  padding: 3.5rem 1.5rem;
}

.placeholder-panel .glyph {
  width: 3.4rem;
  height: 3.4rem;
  margin: 0 auto 1rem;
  display: block;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 0.9rem;
  padding: 0.7rem;
}

.placeholder-panel h3 {
  font-size: 1.2rem;
}

.placeholder-panel p {
  color: var(--ink-soft);
  max-width: 34rem;
  margin: 0 auto 1rem;
}

.soon-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 99px;
  padding: 0.25rem 0.75rem;
}

/* ---------------- API keys ---------------- */

.key-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

.key-form-grid .field-span {
  grid-column: 1 / -1;
}

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

.key-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.key-info {
  min-width: 0;
  flex: 1 1 14rem;
}

.key-label {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-meta {
  font-size: 0.82rem;
  color: var(--ink-soft);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.key-secret {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
}

.empty-note {
  color: var(--ink-soft);
  text-align: center;
  padding: 1.5rem 0;
}

/* ---------------- verify banner ---------------- */

.verify-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--warn-soft);
  border: 1px solid #fde68a;
  color: var(--warn);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
}

.verify-banner form {
  margin: 0;
}

/* ---------------- settings account list ---------------- */

.settings-list {
  margin: 0 0 1.25rem;
}

.settings-list > div {
  display: flex;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.settings-list > div:last-child {
  border-bottom: none;
}

.settings-list dt {
  flex: none;
  width: 7rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.settings-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---------------- toast ---------------- */

.toast-area {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 50;
  max-width: min(22rem, calc(100vw - 2.5rem));
}

.toast {
  background: var(--ink);
  color: #ffffff;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1rem;
  font-size: 0.92rem;
  box-shadow: var(--shadow);
}

.toast.toast-error {
  background: #7f1d1d;
}

.toast.toast-success {
  background: #14532d;
}

/* ---------------- spinner ---------------- */

.spinner {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

.loading-block {
  padding: 3rem 0;
  text-align: center;
  color: var(--ink-soft);
}

/* ---------------- verify-email / reset result screens ---------------- */

.result-card-icon {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.result-card-icon.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.result-card-icon.err {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------------- offline page ---------------- */

.offline-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  padding: 1.5rem;
}

.offline-card {
  width: min(24rem, 100%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  text-align: center;
}

.offline-card .brand {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.noscript-note {
  padding: 1rem;
  text-align: center;
  font-weight: 600;
}

/* ---------------- install page ---------------- */

.install-steps {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  text-align: left;
}

.install-steps li {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}

.step-num {
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-body {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
}

.step-icon {
  flex: none;
  color: var(--accent);
}

.install-fallback-list {
  text-align: left;
  padding-left: 1.2rem;
}

.install-hint {
  font-size: 0.88rem;
  text-align: center;
  margin: 0.75rem 0 0;
}

/* ---------------- responsive ---------------- */

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
  }

  .sidebar-brand {
    margin-bottom: 0.75rem;
  }

  .nav-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
  }

  .nav-link {
    white-space: nowrap;
    padding: 0.5rem 0.7rem;
  }

  .nav-badge {
    display: none;
  }

  .sidebar-foot {
    border-top: none;
    padding-top: 0.75rem;
  }

  .logout-btn {
    width: auto;
  }

  .content {
    padding: 1.25rem;
  }

  .key-form-grid {
    grid-template-columns: 1fr;
  }
}
