:root {
  --primary: #6c63ff;
  --secondary: #03dac6;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-soft: rgba(108, 99, 255, 0.08);
  --surface-strong: #f0f2f8;
  --text: #1a1a2e;
  --text-soft: rgba(26, 26, 46, 0.65);
  --line: rgba(26, 26, 46, 0.08);
  --shadow: 0 28px 80px rgba(62, 61, 108, 0.12);
  --danger: #ff5a79;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
}

:root[data-theme='dark'] {
  --bg: #121220;
  --surface: #1e1e32;
  --surface-soft: rgba(108, 99, 255, 0.16);
  --surface-strong: #24243b;
  --text: #e8e8f0;
  --text-soft: rgba(232, 232, 240, 0.7);
  --line: rgba(255, 255, 255, 0.08);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: 'Inter', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(108, 99, 255, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(3, 218, 198, 0.12), transparent 22%),
    var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

input,
textarea {
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text);
  padding: 14px 16px;
  outline: 2px solid transparent;
  transition: outline-color 0.2s ease, transform 0.2s ease;
}

input:focus,
textarea:focus {
  outline-color: var(--primary);
}

.material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

#app,
.app-shell {
  min-height: 100vh;
}

.app-shell {
  position: relative;
  padding: 24px;
}

.app-shell.has-modal::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(7, 7, 19, 0.42);
  backdrop-filter: blur(14px);
  animation: overlay-fade 0.22s ease both;
}

.splash-screen,
.login-screen {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.login-screen {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 16px 0;
}

.splash-screen {
  gap: 12px;
  text-align: center;
}

.splash-screen h1,
.login-card h1 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.splash-screen p,
.login-copy,
.feature-row span,
.greeting,
.note-card p,
.note-card time,
.muted-copy,
.profile-card span,
.radio-card span,
.info-row span:last-child {
  color: var(--text-soft);
}

.brand-badge,
.empty-badge {
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, var(--primary), rgba(108, 99, 255, 0.7));
  box-shadow: 0 24px 56px rgba(108, 99, 255, 0.35);
}

.brand-badge span,
.empty-badge span {
  font-size: 3.2rem;
}

.splash-badge {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-lg);
  animation: pop-in 0.65s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.login-card {
  width: min(100%, 400px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-badge {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-xl);
  margin-bottom: 28px;
  animation: pop-in 0.75s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.login-copy {
  margin: 10px 0 36px;
  font-size: 1rem;
  line-height: 1.7;
}

.feature-list {
  display: grid;
  gap: 16px;
  margin-bottom: 32px;
}

.feature-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 16px;
  align-items: center;
  animation: fade-up 0.45s ease both;
}

.feature-row:nth-child(2) {
  animation-delay: 0.08s;
}

.feature-row:nth-child(3) {
  animation-delay: 0.16s;
}

.feature-row strong {
  display: block;
  margin-bottom: 4px;
}

.feature-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--primary);
}

.google-mark {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: white;
  color: #4285f4;
  font-weight: 800;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.primary-button {
  background: var(--primary);
  color: white;
  box-shadow: 0 16px 32px rgba(108, 99, 255, 0.28);
}

.secondary-button {
  background: var(--surface-strong);
  color: var(--text);
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.nav-item:hover,
.filter-chip:hover,
.fab:hover,
.bottom-nav button:hover,
.note-card:hover {
  transform: translateY(-1px);
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.login-button,
.block-button {
  width: 100%;
}

.mini-spinner,
.spinner {
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: white;
  animation: spin 1s linear infinite;
}

.mini-spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

.spinner {
  width: 24px;
  height: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  width: min(100%, 1240px);
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 36px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 24px 12px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 24px;
}

.sidebar-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
}

.sidebar-brand-text {
  font-weight: 700;
  color: var(--primary);
}

.sidebar-spacer {
  flex: 1;
}

.nav-item,
.bottom-nav button,
.filter-chip,
.radio-card,
.icon-button,
.avatar-button,
.fab,
.color-chip,
.note-card {
  border-radius: var(--radius-sm);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  color: var(--text-soft);
  padding: 12px 16px;
  margin: 2px 0;
}

.nav-item.is-selected,
.filter-chip.is-selected,
.radio-card.is-selected,
.bottom-nav button.is-selected,
.icon-button.is-active {
  background: var(--surface-soft);
  color: var(--primary);
}

.icon-button,
.avatar-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.icon-button.danger,
.danger-button {
  color: var(--danger);
}

.icon-button.is-favorite {
  background: rgba(255, 193, 7, 0.16);
  color: #f2b200;
}

.avatar-image,
.profile-avatar {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: inherit;
  background: var(--surface-soft);
  background-position: center;
  background-size: cover;
  color: var(--primary);
}

.main-content {
  position: relative;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  min-width: 0;
  padding: 16px 20px 100px;
}

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

.topbar h2 {
  margin: 2px 0 0;
  font-size: clamp(1.6rem, 3vw, 2rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box,
.panel,
.note-card,
.modal,
.bottom-nav,
.toast {
  box-shadow: var(--shadow);
}

.search-box,
.panel,
.note-card,
.modal {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
}

.search-box {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-md);
  padding: 8px 10px 8px 14px;
  margin-bottom: 12px;
}

.search-box input {
  padding: 10px 0;
  background: transparent;
}

.clear-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: transparent;
  color: var(--text-soft);
}

.chip-row,
.editor-chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar,
.editor-chip-row::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.filter-chip.category-chip {
  background:
    linear-gradient(180deg, var(--category-soft-strong), var(--category-soft));
  border-color: var(--category-border);
  color: var(--category-color);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 12px 28px var(--category-glow);
}

.filter-chip.category-chip.is-selected {
  color: var(--category-text);
  border-color: var(--category-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 16px 32px var(--category-glow);
}

.note-area {
  margin-top: 12px;
}

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

.note-card {
  display: flex;
  flex-direction: column;
  min-height: 220px;
  padding: 16px;
  cursor: pointer;
  animation: fade-up 0.4s ease both;
  position: relative;
  overflow: hidden;
}

.note-card > * {
  position: relative;
  z-index: 1;
}

.note-card.category-card {
  border-color: var(--category-border);
  box-shadow:
    var(--shadow),
    inset 0 0 0 1px var(--category-border),
    0 18px 40px var(--category-glow);
}

.note-card.category-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, var(--category-glow), transparent 34%),
    linear-gradient(160deg, var(--category-soft-strong) 0%, transparent 48%);
  pointer-events: none;
  z-index: 0;
}

.note-card-header,
.note-card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.note-card-title strong {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.pin-icon {
  color: var(--primary);
  font-size: 1rem;
}

.star-icon {
  color: #f2b200;
  font-size: 1rem;
}

.note-card p {
  margin: 12px 0 auto;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card time {
  display: block;
  margin-top: 16px;
  font-size: 0.82rem;
}

.note-category-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  margin-top: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--category-border);
  background: var(--category-soft);
  color: var(--category-color);
  font-size: 0.78rem;
  font-weight: 700;
}

.note-category-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.04);
}

.empty-state {
  min-height: calc(100vh - 250px);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px 20px;
}

.empty-badge {
  width: 100px;
  height: 100px;
  margin: 0 auto 24px;
  border-radius: 28px;
  color: var(--primary);
  background: var(--surface-soft);
  box-shadow: none;
}

.fab {
  position: fixed;
  right: calc(32px + env(safe-area-inset-right));
  bottom: calc(32px + env(safe-area-inset-bottom));
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
  box-shadow: 0 22px 38px rgba(108, 99, 255, 0.35);
  z-index: 40;
}

.fab span {
  font-size: 2rem;
}

.bottom-nav {
  display: none;
  position: fixed;
  left: calc(16px + env(safe-area-inset-left));
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  padding: 8px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line);
  z-index: 40;
}

.app-shell.has-modal .fab,
.app-shell.has-modal .bottom-nav {
  opacity: 0;
  pointer-events: none;
}

.bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: transparent;
  color: var(--text-soft);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(7, 7, 19, 0.42);
  backdrop-filter: blur(14px);
  padding: 24px;
}

.overlay-enter {
  animation: overlay-fade 0.22s ease both;
}

.modal {
  width: min(100%, 1120px);
  border-radius: 28px;
}

.app-shell > .modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 60;
  transform: translate(-50%, -50%);
}

.modal-enter {
  animation: modal-rise 0.28s cubic-bezier(0.2, 0.9, 0.2, 1) both;
  transform-origin: center;
}

.modal-header,
.modal-toolbar,
.editor-footer,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header,
.modal-toolbar {
  padding: 22px 24px 0;
}

.modal-header h3 {
  margin: 6px 0 0;
}

.section-kicker,
.panel-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
}

.settings-modal {
  max-width: 640px;
  max-height: min(88vh, 900px);
  overflow: auto;
  padding-bottom: 24px;
}

.settings-stack {
  display: grid;
  gap: 24px;
  padding: 20px 24px 0;
}

.panel {
  border-radius: var(--radius-md);
  padding: 16px;
}

.profile-card,
.category-row,
.info-row,
.radio-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
}

.profile-card strong,
.category-meta strong,
.radio-card strong,
.info-row strong {
  display: block;
  margin-bottom: 4px;
}

.radio-list,
.category-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.radio-card,
.category-row {
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.radio-card > div {
  flex: 1;
  text-align: left;
}

.category-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.category-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

.info-row {
  padding: 4px 0 16px;
}

.compact-modal {
  max-width: 480px;
  padding: 0 24px 24px;
}

.field-label {
  display: block;
  margin: 18px 0 10px;
  font-size: 0.92rem;
  font-weight: 600;
}

.text-input {
  background: var(--surface-strong);
}

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

.color-chip {
  width: 100%;
  aspect-ratio: 1;
  border: 3px solid transparent;
}

.color-chip.is-selected {
  border-color: white;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 45%, transparent);
}

.editor-modal {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: min(86vh, 820px);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.editor-status {
  font-size: 0.9rem;
  color: var(--text-soft);
}

.editor-chip-row {
  padding: 20px 24px 0;
}

.editor-body {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 0;
  padding: 16px 24px 0;
}

.editor-title,
.editor-content {
  background: transparent;
  padding-left: 0;
  padding-right: 0;
}

.editor-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
}

.editor-content {
  min-height: 320px;
  resize: none;
  line-height: 1.8;
}

.editor-divider {
  height: 1px;
  margin: 8px 0 12px;
  background: var(--line);
}

.editor-footer,
.dialog-actions {
  padding: 18px 24px 24px;
}

.dialog-actions {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 90;
  padding: 14px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

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

.slide-in {
  animation: slide-down 0.22s ease both;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.82);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-down {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes overlay-fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modal-rise {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 24px)) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

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

@media (max-width: 1199px) {
  .note-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 799px) {
  .app-shell {
    padding: 0;
  }

  .workspace {
    display: block;
    width: 100%;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .sidebar {
    display: none;
  }

  .main-content {
    padding: 16px 16px 110px;
  }

  .bottom-nav {
    display: flex;
  }

  .fab {
    bottom: calc(124px + env(safe-area-inset-bottom));
  }

  .modal,
  .compact-modal,
  .settings-modal {
    width: 100%;
  }

  .login-screen {
    width: 100%;
    min-height: 100vh;
    padding: 16px;
  }
}

@media (max-width: 799px) and (min-width: 500px) {
  .note-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 499px) {
  .login-card {
    padding: 28px 24px;
  }

  .note-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .modal-toolbar,
  .modal-header,
  .editor-footer,
  .dialog-actions,
  .settings-stack,
  .editor-chip-row,
  .editor-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .overlay {
    padding: 12px;
  }

  .fab {
    right: calc(20px + env(safe-area-inset-right));
    bottom: calc(128px + env(safe-area-inset-bottom));
  }
}
