/* Notebook — soft paper aesthetic
   ivory/cream, charcoal ink, terracotta accent */

:root {
  --paper: #F5F0E6;
  --paper-raised: #FAF7F0;
  --paper-line: #E8E0D4;
  --ink: #3D3A36;
  --ink-muted: #7A746C;
  --ink-faint: #A89F94;
  --accent: #C4785A;
  --accent-soft: #E8C4B4;
  --accent-deep: #A85F45;
  --marker: #C4785A;
  --today-ring: #C4785A;
  --shadow: 0 1px 3px rgba(61, 58, 54, 0.06), 0 4px 16px rgba(61, 58, 54, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --font-serif: "Literata", "Georgia", "Times New Roman", serif;
  --font-sans: "Source Sans 3", system-ui, -apple-system, sans-serif;
  --header-h: 56px;
  --banner-h: 36px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(196, 120, 90, 0.06), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(196, 164, 132, 0.08), transparent 45%),
    var(--paper);
  line-height: 1.5;
}

.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;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 1rem calc(1rem + var(--safe-bottom));
}

/* —— Header —— */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--header-h);
  padding: 0.5rem 0;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo {
  display: flex;
  line-height: 0;
}

.brand-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.clock-label {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.clock-time {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 600;
}

/* —— Banner —— */
.banner {
  background: rgba(196, 120, 90, 0.12);
  border: 1px solid var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  flex-shrink: 0;
}

/* —— Main layout —— */
.main {
  display: grid;
  grid-template-columns: minmax(260px, 300px) 1fr;
  gap: 1.25rem;
  flex: 1;
  align-items: start;
}

@media (max-width: 760px) {
  .main {
    grid-template-columns: 1fr;
  }
}

/* —— Sidebar / Calendar —— */
.sidebar {
  background: var(--paper-raised);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  position: sticky;
  top: 0.75rem;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.calendar-month {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  flex: 1;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 0.35rem;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--ink);
  cursor: pointer;
  position: relative;
  padding: 0;
  transition: background 0.12s ease;
}

.cal-day:hover:not(:disabled) {
  background: rgba(196, 120, 90, 0.1);
}

.cal-day:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.cal-day--other {
  color: var(--ink-faint);
}

.cal-day--today {
  font-weight: 600;
  box-shadow: inset 0 0 0 1.5px var(--today-ring);
}

.cal-day--selected {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.cal-day--selected:hover:not(:disabled) {
  background: var(--accent-deep);
}

.cal-day--selected.cal-day--today {
  box-shadow: none;
}

.cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--marker);
  flex-shrink: 0;
}

.cal-day--selected .cal-dot {
  background: rgba(255, 255, 255, 0.9);
}

.cal-day--other .cal-dot {
  opacity: 0.5;
}

.btn-today {
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.btn-today:hover {
  border-color: var(--accent);
  background: rgba(196, 120, 90, 0.08);
  color: var(--accent-deep);
}

/* —— Buttons —— */
.btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.btn-ghost {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--ink-muted);
  transition: background 0.12s, color 0.12s;
}

.btn-ghost:hover {
  background: rgba(196, 120, 90, 0.12);
  color: var(--ink);
}

.btn-ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn-sm {
  width: auto;
  height: auto;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent-deep);
}

.btn-outline {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-muted);
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: rgba(196, 120, 90, 0.06);
}

/* —— Editor —— */
.editor {
  background: var(--paper-raised);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

@media (max-width: 760px) {
  .editor {
    padding: 1rem;
    min-height: 400px;
  }
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--paper-line);
}

.day-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}

.day-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.save-status {
  font-size: 0.75rem;
  color: var(--ink-faint);
  min-width: 3.5rem;
  text-align: right;
}

.save-status--saving {
  color: var(--ink-muted);
}

.save-status--saved {
  color: var(--accent-deep);
}

.note-title {
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  padding: 0.25rem 0;
  margin-bottom: 0.5rem;
  outline: none;
  letter-spacing: -0.02em;
}

.note-title::placeholder {
  color: var(--ink-faint);
  font-weight: 400;
}

.note-body {
  flex: 1;
  width: 100%;
  min-height: 220px;
  border: none;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink);
  padding: 0.5rem 0;
  resize: vertical;
  outline: none;
  /* subtle ruled-paper feel */
  background-image: repeating-linear-gradient(
    transparent,
    transparent calc(1.7em - 1px),
    var(--paper-line) calc(1.7em - 1px),
    var(--paper-line) 1.7em
  );
  background-attachment: local;
  line-height: 1.7em;
}

.note-body::placeholder {
  color: var(--ink-faint);
  font-style: italic;
}

/* —— Todos —— */
.todos {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--paper-line);
}

.todos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.todos-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid transparent;
}

.todo-item:hover {
  background: rgba(196, 120, 90, 0.04);
  margin: 0 -0.35rem;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
  border-radius: 6px;
}

.todo-check {
  margin-top: 0.2rem;
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.todo-text {
  flex: 1;
  font-size: 0.95rem;
  color: var(--ink);
  word-break: break-word;
  min-width: 0;
}

.todo-item--done .todo-text {
  text-decoration: line-through;
  color: var(--ink-faint);
}

.todo-remove {
  flex-shrink: 0;
  opacity: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
}

.todo-item:hover .todo-remove,
.todo-item:focus-within .todo-remove {
  opacity: 1;
}

.todo-remove:hover {
  color: var(--accent-deep);
  background: rgba(196, 120, 90, 0.12);
}

.todo-form {
  margin-top: 0.35rem;
}

.todo-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--paper-line);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--ink);
  padding: 0.45rem 0;
  outline: none;
  transition: border-color 0.12s;
}

.todo-input:focus {
  border-bottom-color: var(--accent);
}

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

/* —— Footer —— */
.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 0 0.5rem;
  font-size: 0.75rem;
  color: var(--ink-faint);
  flex-shrink: 0;
}

.footer-sep {
  opacity: 0.6;
}

/* —— Mobile polish —— */
@media (max-width: 480px) {
  .app {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .day-title {
    font-size: 1rem;
  }

  .note-title {
    font-size: 1.25rem;
  }

  .clock-time {
    font-size: 1rem;
  }

  .brand-title {
    font-size: 1.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
