@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,500,0,0");
@import url("./utility.css");

:root {
  --ink: #f5f1e8;
  --muted: #a8b2bf;
  --line: #223241;
  --paper: #0e1720;
  --paper-glow-1: rgba(20, 155, 143, 0.18);
  --paper-glow-2: rgba(242, 190, 87, 0.10);
  --paper-glow-3: rgba(255, 111, 97, 0.08);
  --surface: rgba(19, 29, 40, 0.92);
  --surface-2: rgba(15, 24, 33, 0.95);
  --accent: #149b8f;
  --accent-strong: #18b7a7;
  --accent-soft: rgba(20, 155, 143, 0.16);
  --accent-ink: #f7f5ef;
  --tone-cool: #7fd9cc;
  --tone-warm: #f2be57;
  --tone-pop: #ff6f61;
  --danger: #ff7e72;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.32);
  --surface-gradient: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0) 46%);
  --accent-glow: 0 10px 24px rgba(20, 155, 143, 0.16);
}

:root[data-theme="light"] {
  --ink: #182433;
  --muted: #6f7b87;
  --line: #d7ded8;
  --paper: #f7f3ea;
  --paper-glow-1: rgba(20, 155, 143, 0.12);
  --paper-glow-2: rgba(242, 190, 87, 0.16);
  --paper-glow-3: rgba(255, 111, 97, 0.07);
  --surface: rgba(255, 255, 255, 0.92);
  --surface-2: rgba(245, 248, 243, 0.92);
  --accent: #109386;
  --accent-strong: #14a998;
  --accent-soft: rgba(20, 155, 143, 0.12);
  --accent-ink: #ffffff;
  --tone-cool: #149b8f;
  --tone-warm: #ebb34f;
  --tone-pop: #ff6f61;
  --danger: #ca4f43;
  --shadow: 0 20px 48px rgba(24, 36, 51, 0.10);
  --surface-gradient: linear-gradient(180deg, rgba(20, 155, 143, 0.05), rgba(255,255,255,0) 50%);
  --accent-glow: 0 8px 20px rgba(20, 155, 143, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  letter-spacing: 0;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, var(--paper-glow-1), transparent 28%),
    radial-gradient(circle at top right, var(--paper-glow-2), transparent 30%),
    radial-gradient(circle at 72% 92%, var(--paper-glow-3), transparent 24%),
    var(--paper);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  filter: blur(50px);
}

body::before {
  width: 240px;
  height: 240px;
  left: -80px;
  top: 18vh;
  background: radial-gradient(circle, color-mix(in srgb, var(--tone-cool) 20%, transparent), transparent 70%);
}

body::after {
  width: 220px;
  height: 220px;
  right: -70px;
  bottom: 8vh;
  background: radial-gradient(circle, color-mix(in srgb, var(--tone-warm) 18%, transparent), transparent 72%);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1.05;
  margin-bottom: 0.6rem;
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 0;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.app-shell.auth-shell {
  display: block;
}

.sidebar {
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 84%, var(--surface) 16%), var(--surface-2)),
    var(--surface-2);
  backdrop-filter: blur(14px);
  padding: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  display: block;
  margin-bottom: 28px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.brand-banner-shell {
  display: grid;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, white 18%);
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(250,246,238,0.92));
  box-shadow: 0 12px 28px rgba(8, 20, 31, 0.12);
}

.brand-banner-image {
  display: block;
  width: min(176px, 100%);
  height: auto;
}

.auth-brand {
  display: grid;
  justify-items: center;
  margin-bottom: 4px;
}

.auth-brand-shell {
  justify-items: center;
}

.material-symbols-rounded {
  direction: ltr;
  display: inline-flex;
  flex: 0 0 auto;
  font-family: "Material Symbols Rounded";
  font-feature-settings: "liga";
  font-size: 1.25em;
  font-style: normal;
  font-weight: normal;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
}

.nav {
  display: grid;
  gap: 8px;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  gap: 8px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  color: var(--ink);
}

.nav a.active,
.nav a:hover {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, var(--surface)), var(--surface));
  box-shadow: 0 10px 22px color-mix(in srgb, var(--accent) 18%, transparent);
}

.sidebar-card {
  margin-top: 28px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sidebar-card p {
  margin: 6px 0 0;
  font-size: 0.9rem;
}

.page {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.presence-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.presence-summary span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.9rem;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.auth-card {
  width: min(440px, 100%);
  margin: 8vh auto;
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  align-content: center;
  padding: 18px;
  background: var(--paper);
}

.auth-theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
}

.auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
}

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

.eyebrow {
  display: inline-block;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0;
}

.grid {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.hero-panel {
  background: var(--surface-gradient), var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel {
  padding: 18px;
}

.hero-panel {
  min-height: 260px;
  padding: 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 22px;
  overflow: hidden;
  position: relative;
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: -30% -10% auto auto;
  width: 280px;
  height: 280px;
  border-radius: 999px;
  background: radial-gradient(circle, color-mix(in srgb, var(--tone-cool) 32%, transparent), transparent 68%);
  pointer-events: none;
}

.hero-panel::after {
  content: "";
  position: absolute;
  inset: auto auto -80px -60px;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: radial-gradient(circle, color-mix(in srgb, var(--tone-pop) 18%, transparent), transparent 70%);
  pointer-events: none;
}

.hero-panel > * {
  position: relative;
  z-index: 1;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-header a {
  color: var(--accent);
  font-weight: 700;
}

.stack {
  display: grid;
  gap: 10px;
}

.primary,
.secondary,
.ghost,
.chip,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 800;
}

button:disabled,
.is-loading {
  cursor: wait;
  opacity: 0.72;
}

.spinner {
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

.primary .spinner,
.secondary .spinner,
.ghost .spinner,
.page-busy .spinner {
  margin-right: 8px;
}

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

.page-busy {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  backdrop-filter: blur(2px);
}

.page-busy > div {
  display: inline-flex;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: none;
}

.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.ghost {
  background: transparent;
  color: var(--accent);
  border: 0;
  box-shadow: none;
}

.chip {
  background: transparent;
  color: var(--accent);
  border: 0;
  box-shadow: none;
}

.ghost:hover {
  background: color-mix(in srgb, var(--accent-soft) 70%, transparent);
}

.chip.active,
.chip:hover {
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  background: color-mix(in srgb, var(--accent-soft) 82%, var(--surface));
}

.danger {
  color: var(--danger);
}

.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.85rem;
}

.icon-only {
  width: 42px;
  padding: 0;
  font-size: 1.05rem;
}

.small.icon-only {
  width: 34px;
}

.full {
  width: 100%;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  box-shadow: none;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent-strong) 78%, white 22%);
  outline-offset: 2px;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: var(--ink);
}

.empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 20px);
  opacity: 0;
  background: var(--ink);
  color: var(--surface);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 50;
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--accent);
  color: #111111;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(32, 33, 36, 0.48);
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  align-items: end;
  background: rgba(0, 0, 0, 0.42);
  padding: 12px;
}

.error-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  align-items: end;
  background: rgba(32, 33, 36, 0.18);
  padding: 14px;
}

.error-sheet {
  width: min(720px, 100%);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  background: var(--surface);
  border: 1px solid #efafa9;
  border-left: 6px solid var(--danger);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.error-sheet h2 {
  margin: 4px 0;
}

.error-sheet p {
  margin: 0;
}

.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.bottom-sheet {
  width: min(680px, 100%);
  max-height: min(78vh, 720px);
  margin: 0 auto;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  box-shadow: var(--shadow);
  animation: sheetRise 0.18s ease-out;
}

@keyframes sheetRise {
  from {
    transform: translateY(18px);
    opacity: 0.72;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-create {
  border-top: 6px solid var(--accent);
}

.modal-edit {
  border-top: 6px solid var(--tone-cool);
}

.modal-vault {
  border-top: 6px solid var(--tone-warm);
}

.modal-delete {
  border-top: 6px solid var(--danger);
}

.modal-header,
.modal-actions,
.sheet-header,
.sheet-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2,
.sheet-header h2 {
  margin: 4px 0 0;
}

.modal-actions,
.sheet-actions {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-body,
.sheet-body {
  padding: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wide {
  grid-column: 1 / -1;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkline input {
  width: auto;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    position: fixed;
    inset: auto 0 0;
    z-index: 35;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.22);
  }

  .brand {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .nav a {
    min-height: 56px;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    font-size: 0.7rem;
    padding: 7px 4px;
  }

  .nav a span:last-child:not(.material-symbols-rounded) {
    display: inline;
  }

  .sidebar-card {
    display: none;
  }

  .page {
    padding: 14px 14px 92px;
  }

  .topbar {
    justify-content: flex-end;
  }

  .grid.two,
  .grid.three,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    margin-bottom: 12px;
  }

  .user-pill > span:not(.avatar) {
    max-width: 34vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sheet-backdrop {
    padding: 0;
  }

  .bottom-sheet {
    width: 100%;
    max-height: 84vh;
    border-radius: 8px 8px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
}
