:root,
[data-theme="dark"] {
  --bg: #000000;
  --fg: #ffffff;
  --muted: #8a8a8a;
  --sun: #c45c6a;
  --sat: #4a8fd4;
  --select: #2f6fed;
  --danger: #e85d5d;
  --line: #1a1a1a;
  --panel: #141414;
  --panel-border: #2a2a2a;
  --hero-glow-1: #1a2333;
  --hero-glow-2: #121820;
  --input-line: #333;
  --toast-bg: #1c1c1c;
  --font: "Inter", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f5f7;
  --fg: #12141a;
  --muted: #6b7280;
  --sun: #c04555;
  --sat: #2f6fbf;
  --select: #2f6fed;
  --danger: #d64545;
  --line: #e2e4e8;
  --panel: #ffffff;
  --panel-border: #dde1e6;
  --hero-glow-1: #dfe8f5;
  --hero-glow-2: #ebe4d8;
  --input-line: #c8ccd2;
  --toast-bg: #ffffff;
  color-scheme: light;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
}

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

button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  appearance: none;
}

#app {
  min-height: 100dvh;
  min-height: 100svh;
}

/* —— Landing —— */
.landing {
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: calc(28px + var(--safe-top)) 28px calc(28px + var(--safe-bottom));
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, var(--hero-glow-1) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 80% 100%, var(--hero-glow-2) 0%, transparent 50%),
    var(--bg);
}

.landing-brand {
  font-size: clamp(2.4rem, 10vw, 3.2rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 0 0 12px;
}

.landing-tag {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.45;
  max-width: 18rem;
}

.landing-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 20px;
  padding-top: 48px;
}

.auth-tabs {
  display: flex;
  gap: 24px;
}

.auth-tab {
  color: var(--muted);
  font-size: 0.95rem;
  padding-bottom: 6px;
  border-bottom: 2px solid transparent;
}

.auth-tab.active {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

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

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.auth-form input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--input-line);
  padding: 10px 0;
  outline: none;
  font-size: 1.05rem;
}

.auth-form input:focus {
  border-bottom-color: var(--fg);
}

.auth-error {
  min-height: 1.2em;
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0;
}

.btn-primary {
  margin-top: 8px;
  background: var(--fg);
  color: var(--bg);
  border-radius: 999px;
  padding: 14px 20px;
  font-weight: 600;
  font-size: 1rem;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.5;
}

/* —— Calendar —— */
.screen {
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  animation: fade-in 0.22s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 12px 16px 8px;
  min-height: 56px;
}

.cal-settings {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  color: var(--muted);
}

.cal-settings:hover,
.cal-settings[aria-expanded="true"] {
  color: var(--fg);
}

.cal-month {
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 0;
}

.cal-nav {
  position: absolute;
  inset: 12px 8px auto;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  padding-left: 44px;
}

.cal-nav button {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.cal-header:hover .cal-nav button,
.cal-nav button:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .cal-nav button {
    opacity: 0.45;
  }
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 12px 8px 4px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--fg);
  font-weight: 500;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  flex: 1;
  padding: 0 4px 12px;
  align-content: start;
  row-gap: 8px;
}

.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 64px;
  padding: 6px 0 10px;
  border: none;
  background: none;
  color: var(--fg);
  position: relative;
  transition: transform 0.12s ease;
}

.cal-cell:active {
  transform: scale(0.94);
}

.cal-cell.empty {
  pointer-events: none;
}

.cal-day {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1;
}

.cal-cell.sun .cal-day {
  color: var(--sun);
}

.cal-cell.sat .cal-day {
  color: var(--sat);
}

.cal-cell.selected .cal-day {
  background: var(--select);
  color: var(--fg);
}

.note-dot {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--fg);
  border-radius: 50%;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.cal-cell.has-note .note-dot {
  opacity: 1;
  transform: scale(1);
}

.note-dot svg {
  width: 10px;
  height: 10px;
}

.cal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px calc(12px + var(--safe-bottom));
}

.cal-footer .user {
  font-size: 0.8rem;
  color: var(--muted);
}

.cal-footer .logout {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* —— Note editor —— */
.note-screen {
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  animation: slide-in 0.25s ease;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

.note-top {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: start;
  padding: 12px 8px 4px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--fg);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.note-meta {
  text-align: center;
  padding-top: 8px;
}

.note-date {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.note-count {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.note-count.over {
  color: var(--danger);
}

.note-body {
  flex: 1;
  display: flex;
  padding: 8px 20px 0;
}

.note-body textarea {
  width: 100%;
  height: 100%;
  min-height: 40vh;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1.05rem;
  line-height: 1.55;
  caret-color: var(--select);
  padding: 0;
}

.note-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px calc(16px + var(--safe-bottom));
}

.note-bottom .spacer {
  width: 44px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  background: var(--toast-bg);
  color: var(--fg);
  border: 1px solid var(--panel-border);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

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

.hidden {
  display: none !important;
}

/* —— Settings sheet —— */
.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
  animation: fade-in 0.18s ease;
}

[data-theme="light"] .settings-backdrop {
  background: rgba(18, 20, 26, 0.28);
}

.settings-sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  top: calc(56px + var(--safe-top));
  z-index: 41;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px 16px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  animation: sheet-in 0.2s ease;
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.settings-sheet h2 {
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.settings-label {
  margin: 0 0 8px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.theme-option {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.theme-option svg {
  width: 20px;
  height: 20px;
}

.theme-option.active {
  border-color: var(--select);
  color: var(--fg);
  background: color-mix(in srgb, var(--select) 12%, transparent);
}

html {
  background: var(--bg);
}

