:root {
  --bg: #000000;
  --panel: #000000;
  --panel-soft: #0f0f10;
  --line: #262626;
  --text: #f5f5f5;
  --muted: #a8a8a8;
  --sidebar-width: 244px;
  --sidebar-collapsed: 78px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Instrument Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar-overlay {
  display: none;
}

.mobile-menu-button {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: var(--sidebar-width);
  height: 100vh;
  padding: 1rem 0.75rem 1.5rem;
  border-right: 1px solid var(--line);
  background: var(--panel);
  transition: width 220ms ease, padding 220ms ease;
}

.sidebar.is-collapsed {
  width: var(--sidebar-collapsed);
  padding-inline: 0.55rem;
  border-right-color: transparent;
  background: transparent;
  box-shadow: none;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.5rem;
}

.icon-button,
.action-button,
.mobile-menu-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
}

.mobile-menu-button {
  position: fixed;
  left: 0.8rem;
  top: 0.8rem;
  z-index: 25;
  align-items: center;
  justify-content: center;
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 999px;
  background: rgba(15, 15, 16, 0.92);
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
  color: var(--text);
}

.mobile-menu-button span {
  position: absolute;
  width: 1rem;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.mobile-menu-button span:first-child {
  transform: translateY(-4px);
}

.mobile-menu-button span:last-child {
  transform: translateY(4px);
}

.sidebar-toggle {
  position: relative;
}

.sidebar-toggle span {
  position: absolute;
  width: 0.95rem;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 220ms ease;
}

.sidebar-toggle span:first-child {
  transform: translateY(-4px);
}

.sidebar-toggle span:last-child {
  transform: translateY(4px);
}

.sidebar.is-collapsed .sidebar-toggle span:first-child {
  transform: rotate(45deg);
}

.sidebar.is-collapsed .sidebar-toggle span:last-child {
  transform: rotate(-45deg);
}

.brand {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  height: 2.5rem;
  flex: 1;
  overflow: hidden;
}

.brand-image,
.nav-label {
  transition: opacity 180ms ease, transform 180ms ease;
}

.brand-image {
  position: absolute;
  left: 0;
  top: 50%;
  display: block;
  height: auto;
  transform: translateY(-50%);
}

.brand-image-full {
  width: 170px;
  opacity: 1;
}

.brand-image-icon {
  width: 34px;
  opacity: 0;
  pointer-events: none;
}

.sidebar-nav {
  display: grid;
  gap: 0.2rem;
}

.sidebar-account-row {
  margin-top: auto;
  padding: 0.35rem 0.85rem 0;
}

.sidebar-auth-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 44px;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.sidebar-auth-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
}

.sidebar-auth-image {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  object-fit: contain;
}

.sidebar-auth-label {
  white-space: nowrap;
}

.sidebar.is-collapsed .sidebar-account-row {
  padding-inline: 0.15rem;
}

.sidebar.is-collapsed .sidebar-auth-button {
  width: 100%;
  min-width: 0;
  padding-inline: 0;
}

.sidebar.is-collapsed .sidebar-auth-label {
  display: none;
}

.sidebar.is-collapsed .sidebar-nav,
.sidebar.is-collapsed .sidebar-account-row {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.8rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
}

.nav-link:hover,
.nav-link.is-active {
  background: transparent;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
}

.nav-icon-image {
  display: block;
  width: 1.3rem;
  height: 1.3rem;
  object-fit: contain;
}

.nav-icon-plus {
  font-size: 1.9rem;
  line-height: 1;
  font-weight: 300;
}

.sidebar.is-collapsed .brand-image-full,
.sidebar.is-collapsed .nav-label {
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
}

.sidebar.is-collapsed .brand {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  overflow: visible;
}

.sidebar.is-collapsed .brand-image-icon {
  left: 0;
  opacity: 1;
  transform: translateY(-50%);
  pointer-events: auto;
}

.settings-main {
  flex: 1;
  max-width: 1120px;
  padding: 1.75rem 2rem 3rem;
}

.settings-header,
.settings-grid,
.settings-form,
.card-head {
  display: grid;
  gap: 1rem;
}

.settings-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.settings-trust-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}

.settings-trust-links a {
  color: var(--muted);
}

.page-kicker,
.section-kicker {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-copy,
.helper-text,
.toggle-row p {
  color: var(--muted);
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1.4rem;
}

.settings-card {
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
}

.wide-card {
  grid-column: span 2;
}

.card-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  margin-bottom: 1rem;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.84rem;
}

.status-tag[data-status-tone="neutral"] {
  border-color: var(--line);
  color: var(--muted);
}

.status-tag[data-status-tone="saving"] {
  border-color: rgba(245, 245, 245, 0.18);
  color: #d5d5d5;
}

.status-tag[data-status-tone="success"] {
  border-color: rgba(115, 222, 164, 0.28);
  color: #8ce7b6;
}

.status-tag[data-status-tone="error"] {
  border-color: rgba(255, 111, 111, 0.26);
  color: #ff8d8d;
}

.settings-form {
  gap: 0.9rem;
}

.form-row {
  display: grid;
  gap: 0.45rem;
}

.form-row span,
.toggle-row strong {
  font-weight: 600;
}

.form-row input {
  width: 100%;
  min-height: 50px;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  color: var(--text);
  outline: none;
}

.form-row input:focus {
  border-color: #3a3a3a;
}

.action-button {
  justify-self: start;
  min-height: 48px;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: #323232;
  color: #ffffff;
  font-weight: 600;
}

.password-rules {
  display: grid;
  gap: 0.45rem;
  margin: -0.15rem 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.password-rules li.is-met {
  color: #8ce7b6;
}

.privacy-form {
  gap: 1rem;
}

.support-card {
  gap: 1rem;
}

.danger-card {
  border-color: rgba(255, 111, 111, 0.18);
}

.support-links {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.2rem 0;
}

.toggle-row p {
  margin: 0.35rem 0 0;
}

.toggle-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #ffffff;
}

.danger-button {
  background: #3a1010;
  color: #ffd1d1;
  border: 1px solid rgba(255, 111, 111, 0.24);
}

.danger-button:hover,
.danger-button:focus-visible {
  background: #4a1414;
}

@media (max-width: 900px) {
  .settings-header,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .wide-card {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    z-index: 30;
    width: 100%;
    height: auto;
    padding: 0.55rem 0.75rem calc(0.55rem + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.94);
    backdrop-filter: blur(14px);
    box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.35);
    transition: none;
  }

  .sidebar.is-collapsed {
    width: 100%;
    height: auto;
    padding: 0.55rem 0.75rem calc(0.55rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.94);
    box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.35);
  }

  .sidebar.is-collapsed .sidebar-nav {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
  }

  .brand-row,
  .sidebar-account-row {
    display: none;
  }

  .sidebar-nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .nav-link {
    justify-content: center;
    min-height: 56px;
    padding: 0.55rem 0.25rem;
    border-radius: 16px;
  }

  .nav-label {
    display: none;
  }

  .nav-icon {
    width: 2.1rem;
    height: 2.1rem;
  }

  .nav-icon-image {
    width: 1.45rem;
    height: 1.45rem;
  }

  .settings-main {
    padding: 1rem 1rem calc(6.5rem + env(safe-area-inset-bottom));
  }

  .toggle-row {
    grid-template-columns: 1fr;
  }

  .ghost-link,
  .action-button {
    width: 100%;
    justify-self: stretch;
  }

  .card-head {
    grid-template-columns: 1fr;
  }

  .status-tag {
    justify-self: start;
  }

  .support-links,
  .settings-trust-links {
    flex-direction: column;
    align-items: stretch;
  }
}
