:root {
  color-scheme: light dark;
  --bg: #f4ede1;
  --bg-accent: rgba(210, 154, 79, 0.2);
  --paper: rgba(255, 246, 209, 0.9);
  --paper-edge: rgba(255, 255, 255, 0.72);
  --ink: #34291f;
  --muted: #73614e;
  --border: rgba(124, 90, 44, 0.18);
  --focus: #8d5b1e;
  --button: rgba(255, 255, 255, 0.52);
  --button-hover: rgba(255, 255, 255, 0.82);
  --status-saving: #8c5a17;
  --status-error: #8d2e2e;
  --shadow: 0 32px 80px rgba(88, 58, 20, 0.16);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1814;
    --bg-accent: rgba(208, 153, 77, 0.16);
    --paper: rgba(73, 59, 33, 0.88);
    --paper-edge: rgba(255, 255, 255, 0.06);
    --ink: #f7eed8;
    --muted: #d8c7a8;
    --border: rgba(255, 230, 184, 0.09);
    --focus: #ffd28b;
    --button: rgba(255, 255, 255, 0.08);
    --button-hover: rgba(255, 255, 255, 0.14);
    --status-saving: #ffd28b;
    --status-error: #ff9d9d;
    --shadow: 0 38px 90px rgba(0, 0, 0, 0.38);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100svh;
  background:
    radial-gradient(circle at top left, var(--bg-accent), transparent 36%),
    radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.16), transparent 30%),
    var(--bg);
  color: var(--ink);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 24rem;
  height: 24rem;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(50px);
  opacity: 0.28;
}

body::before {
  top: -6rem;
  right: -4rem;
  background: rgba(255, 219, 112, 0.44);
}

body::after {
  bottom: -7rem;
  left: -5rem;
  background: rgba(255, 255, 255, 0.24);
}

.app-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.note-card {
  width: min(100%, 52rem);
  min-height: min(82svh, 48rem);
  display: grid;
  gap: 1rem;
  padding: 1.35rem;
  border: 1px solid var(--border);
  border-radius: 1.75rem;
  background:
    linear-gradient(180deg, var(--paper-edge), transparent 20%),
    var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.note-header,
.utility-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.title-group {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#note-heading {
  margin: 0;
  font-size: clamp(1.4rem, 1.2rem + 1vw, 2rem);
  line-height: 1.1;
}

.utility-group {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.save-status {
  margin: 0;
  min-width: 4.5rem;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

.save-status[data-status="saving"] {
  color: var(--status-saving);
}

.save-status[data-status="error"] {
  color: var(--status-error);
}

.clear-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--button);
  color: inherit;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease, transform 160ms ease;
}

.clear-button:hover {
  background: var(--button-hover);
  transform: translateY(-1px);
}

.clear-button:focus-visible,
.note-input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.clear-hint {
  min-height: 1.25rem;
  margin: -0.35rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.note-input {
  width: 100%;
  min-height: 18rem;
  height: 100%;
  flex: 1;
  resize: vertical;
  border: 1px solid transparent;
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  padding: 1.25rem;
  font: 400 clamp(1.05rem, 0.98rem + 0.45vw, 1.28rem) / 1.65 "Iowan Old Style",
    "Palatino Linotype", "Book Antiqua", Georgia, serif;
  caret-color: var(--focus);
  overflow: auto;
}

.note-input::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .note-card {
    min-height: calc(100svh - 2rem);
    padding: 1rem;
    border-radius: 1.4rem;
  }

  .note-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .utility-group {
    width: 100%;
    justify-content: space-between;
  }

  .note-input {
    min-height: 22rem;
    padding: 1rem;
  }
}
