:root {
  --bg-canvas: #060607;
  --bg-surface: rgba(20, 20, 22, 0.84);
  --bg-surface-strong: rgba(28, 28, 31, 0.92);
  --bg-surface-hover: rgba(38, 38, 42, 0.94);
  --bg-input: rgba(12, 12, 14, 0.92);

  --border-subtle: rgba(255, 255, 255, 0.085);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-strong: rgba(255, 255, 255, 0.34);

  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.72);
  --text-muted: rgba(255, 255, 255, 0.44);
  --text-faint: rgba(255, 255, 255, 0.28);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-card:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 18px 42px rgba(0, 0, 0, 0.55);

  --font-active: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --transition: 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-active);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-image:
    radial-gradient(ellipse 80% 55% at 50% -12%, rgba(255, 255, 255, 0.065), transparent 72%),
    radial-gradient(ellipse 60% 45% at 85% 110%, rgba(255, 255, 255, 0.03), transparent 70%);
  background-attachment: fixed;
}

button,
input,
textarea {
  font-family: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

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

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(6, 6, 7, 0.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 13px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  user-select: none;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.14em;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  transition: opacity var(--transition), transform var(--transition);
}

.sync-pill[data-state="syncing"] .sync-dot {
  animation: pulseDot 1s ease-in-out infinite;
}

.sync-pill[data-state="error"] .sync-dot,
.sync-pill[data-state="offline"] .sync-dot {
  background: rgba(255, 255, 255, 0.34);
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.25; transform: scale(0.75); }
}

.icon-btn,
.chip-btn,
.ghost-btn {
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.icon-btn {
  width: 32px;
  padding: 0;
}

.icon-btn.spinning svg {
  animation: spin 0.85s linear infinite;
}

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

.chip-btn {
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.ghost-btn {
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 500;
}

.icon-btn:hover,
.chip-btn:hover,
.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.icon-btn:active,
.chip-btn:active,
.ghost-btn:active {
  transform: scale(0.96);
}

.user-menu {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-left: 6px;
  border-left: 1px solid var(--border-subtle);
}

.user-handle {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Warning Banner */
.banner {
  border-bottom: 1px solid var(--border-medium);
  background: rgba(255, 255, 255, 0.06);
}

.banner-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 22px;
  font-size: 13px;
  color: var(--text-secondary);
}

.banner-inner strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 3px;
}

.banner-inner p {
  margin: 0;
  line-height: 1.45;
}

/* Main */
.main-wrap {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 34px 22px 64px;
}

/* Auth Stage */
.auth-stage {
  min-height: calc(100vh - 170px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  padding: 30px 28px 26px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  animation: fadeSlideUp 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-header {
  text-align: center;
  margin-bottom: 22px;
}

.auth-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.seg-btn.active {
  background: #ffffff;
  color: #060607;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.text-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 14.5px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

.text-input::placeholder {
  color: var(--text-faint);
}

.text-input:focus {
  border-color: var(--border-strong);
  background: rgba(16, 16, 19, 1);
}

.password-wrap {
  position: relative;
}

.password-wrap .text-input {
  padding-right: 44px;
}

.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.pw-toggle:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.07);
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #ffffff;
  font-size: 13px;
  line-height: 1.45;
}

.primary-btn {
  margin-top: 4px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: #ffffff;
  color: #060607;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}

.primary-btn:hover {
  opacity: 0.9;
}

.primary-btn:active {
  transform: scale(0.985);
}

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

.auth-footnote {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Workspace */
.workspace {
  animation: fadeSlideUp 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.workspace-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.workspace-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.workspace-meta {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.search-wrap {
  position: relative;
  width: 260px;
  max-width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

.search-input::placeholder {
  color: var(--text-faint);
}

.search-input:focus {
  border-color: var(--border-strong);
  background: var(--bg-surface-strong);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.surface-card {
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

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

.notes-header {
  padding: 0 4px;
}

.section-title-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-label {
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.section-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
}

.text-action {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: color var(--transition), background var(--transition);
}

.text-action:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.07);
}

/* Checklist */
.add-task-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.add-task-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 13px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.add-task-input::placeholder {
  color: var(--text-faint);
}

.add-task-input:focus {
  border-color: var(--border-strong);
}

.square-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid var(--border-medium);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.square-btn:hover {
  background: #ffffff;
  color: #060607;
}

.square-btn:active {
  transform: scale(0.95);
}

.checklist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.check-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  user-select: none;
}

.check-row:hover {
  background: rgba(255, 255, 255, 0.045);
}

.check-row.dragging {
  z-index: 20;
  background: rgba(34, 34, 38, 0.96);
  border-color: var(--border-medium);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  transition: none;
}

.check-toggle {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1.6px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: #060607;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.check-toggle:hover {
  border-color: #ffffff;
}

.check-row.checked .check-toggle {
  background: #ffffff;
  border-color: #ffffff;
}

.check-text-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 14.5px;
  line-height: 1.4;
  padding: 2px 4px;
  border-radius: 6px;
  outline: none;
}

.check-text-input:focus {
  background: rgba(255, 255, 255, 0.06);
}

.check-row.checked .check-text-input {
  color: var(--text-muted);
  text-decoration: line-through;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
}

.check-row:hover .row-actions,
.check-row:focus-within .row-actions,
.check-row.dragging .row-actions {
  opacity: 1;
}

.drag-handle {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  transition: background var(--transition), color var(--transition);
}

.drag-handle:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
}

.check-row.dragging .drag-handle,
.drag-handle:active {
  cursor: grabbing;
  color: var(--text-primary);
}

.mini-icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.mini-icon-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
}

.empty-hint {
  margin: 8px 4px 2px;
  font-size: 13px;
  color: var(--text-faint);
}

/* Quick Notes */
.new-note-btn {
  height: 34px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--border-medium);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.new-note-btn:hover {
  background: #ffffff;
  color: #060607;
}

.new-note-btn:active {
  transform: scale(0.97);
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.note-card {
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  padding: 18px 18px 14px;
  transition: border-color var(--transition), background var(--transition);
}

.note-card:focus-within {
  border-color: var(--border-strong);
  background: var(--bg-surface-strong);
}

.note-textarea {
  width: 100%;
  min-height: 124px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.62;
  resize: none;
  outline: none;
  overflow: hidden;
  display: block;
}

.note-textarea::placeholder {
  color: var(--text-faint);
}

.note-footer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.note-time {
  font-size: 11.5px;
  color: var(--text-faint);
}

.note-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: #ffffff;
  color: #060607;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  animation: fadeSlideUp 180ms ease-out;
}

/* Responsive */
@media (max-width: 860px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
  .search-wrap {
    width: 100%;
  }
  .row-actions {
    opacity: 1;
  }
}

@media (max-width: 520px) {
  .topbar-inner {
    padding: 11px 14px;
  }
  .main-wrap {
    padding: 20px 14px 48px;
  }
  .auth-card {
    padding: 24px 18px 20px;
  }
  .user-handle {
    display: none;
  }
}
