.app-header {
  text-align: center;
  padding: 22px 0 8px;
}
.app-header h1 {
  margin: 0;
  letter-spacing: .5px;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 20px;
  padding: 16px 24px 40px;
  align-items: start;
  max-width: 1400px;
  margin: 0 auto;
}

.column {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.column h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

/* ---------- TO-DO ---------- */
.todo-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.todo-form input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .9rem;
  outline: none;
}
.todo-form input:focus { border-color: var(--accent); }
.todo-form button {
  width: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.todo-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: .9rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
  animation: pop .18s ease;
}
.todo-pill.done .pill-text {
  text-decoration: line-through;
  opacity: .55;
}
.pill-check {
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  flex: 0 0 auto;
  cursor: pointer;
}
.pill-check:checked {
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--accent-soft);
}
.pill-text { flex: 1; word-break: break-word; }
.pill-del {
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}
.pill-del:hover { color: var(--accent); }

@keyframes pop {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---------- CALENDAR ---------- */
.view-switch {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: 999px;
  padding: 4px;
  margin: 0 auto 14px;
  width: fit-content;
}
.view-switch button {
  background: transparent;
  color: var(--muted);
  padding: 7px 22px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.view-switch button.active {
  background: var(--accent);
  color: #fff;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.calendar-toolbar h2 { margin: 0; }
.calendar-toolbar button {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg);
  font-size: 1.4rem;
  line-height: 1;
}
.calendar-toolbar button:hover { background: var(--accent-soft); }

.weekday-row, .calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.weekday-row {
  margin-bottom: 8px;
  font-size: .75rem;
  color: var(--muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.day {
  min-height: 92px;
  background: var(--bg);
  border-radius: 10px;
  padding: 6px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: outline .12s;
}
.day.empty { background: transparent; }
.day.outside { opacity: .45; }
.day.today {
  outline: 2px solid var(--accent);
}

/* Week view: fewer, taller cells */
.calendar-grid.week-mode .day {
  min-height: 230px;
}
.day.drag-over {
  outline: 2px dashed var(--accent);
  background: #fff7ee;
}
.day-num {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
}
.day.today .day-num { color: var(--accent); }

/* notes placed on a day */
.day-note {
  background: var(--note-yellow);
  border-radius: 6px;
  padding: 5px 18px 5px 7px;
  font-size: .72rem;
  line-height: 1.25;
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
  word-break: break-word;
  cursor: default;
}
.day-note.pink   { background: var(--note-pink); }
.day-note.green  { background: var(--note-green); }
.day-note.blue   { background: var(--note-blue); }
.day-note .note-del {
  position: absolute;
  top: 1px; right: 3px;
  background: transparent;
  font-size: .8rem;
  color: rgba(0,0,0,.45);
  line-height: 1;
}
.day-note .note-del:hover { color: #000; }

/* ---------- STICKY NOTE COMPOSER ---------- */
.hint {
  font-size: .78rem;
  color: var(--muted);
  margin: -6px 0 14px;
  line-height: 1.4;
}
.sticky-pad {
  background: var(--note-yellow);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow);
  transition: background .15s;
}
.sticky-pad textarea {
  width: 100%;
  min-height: 90px;
  border: none;
  background: transparent;
  resize: vertical;
  font-family: inherit;
  font-size: .9rem;
  outline: none;
}
.note-colors {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}
.swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid rgba(0,0,0,.15);
}
.swatch.active { border-color: #000; transform: scale(1.15); }
.create-note-btn {
  width: 100%;
  padding: 9px;
  border-radius: 8px;
  background: rgba(0,0,0,.78);
  color: #fff;
  font-size: .85rem;
}
.create-note-btn:hover { background: #000; }

.note-tray {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tray-note {
  background: var(--note-yellow);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .8rem;
  box-shadow: var(--shadow);
  cursor: grab;
  position: relative;
  word-break: break-word;
}
.tray-note.pink  { background: var(--note-pink); }
.tray-note.green { background: var(--note-green); }
.tray-note.blue  { background: var(--note-blue); }
.tray-note:active { cursor: grabbing; }
.tray-note small {
  display: block;
  margin-top: 4px;
  color: rgba(0,0,0,.5);
  font-size: .68rem;
}
.tray-note .tray-del {
  position: absolute;
  top: 2px; right: 5px;
  background: transparent;
  color: rgba(0,0,0,.45);
  font-size: .9rem;
  line-height: 1;
}

/* ---------- SAVE STATE + SAVED ROW ---------- */
.save-state-btn {
  width: 100%;
  margin-top: 16px;
  padding: 11px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: background .15s, transform .1s;
}
.save-state-btn:hover { background: #c9684f; }
.save-state-btn:active { transform: scale(.98); }
.save-state-btn:disabled { opacity: .5; cursor: not-allowed; }

.share-board-btn {
  width: 100%;
  margin-top: 10px;
  padding: 11px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: .9rem;
  font-weight: 600;
  transition: background .15s, transform .1s;
}
.share-board-btn:hover { background: var(--accent-soft); }
.share-board-btn:active { transform: scale(.98); }

.share-msg {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #e6f4ea;
  color: #1f6b3a;
  font-size: .78rem;
  line-height: 1.4;
  word-break: break-all;
}
.share-msg.error { background: #fdeaea; color: #9b2c2c; }
.share-msg a { color: inherit; font-weight: 600; }

.saved-row {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 48px;
}
.saved-row h2 { margin: 0 0 4px; font-size: 1.1rem; }
.saved-count { color: var(--muted); font-weight: 400; font-size: .9rem; }
.saved-row .hint { margin: 0 0 14px; }

.saved-slots {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}
.saved-slot {
  position: relative;
  border-radius: 12px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.saved-slot.filled { cursor: pointer; border: 1px solid var(--line); }
.saved-slot.filled:hover { outline: 2px solid var(--accent); }
.saved-slot.empty {
  border: 2px dashed var(--line);
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .8rem;
}
.saved-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.saved-slot .slot-label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  color: #fff;
  font-size: .7rem;
  padding: 14px 8px 6px;
}
.saved-slot .slot-del {
  position: absolute;
  top: 6px; right: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.saved-slot .slot-del:hover { background: var(--accent); }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .saved-slots { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  html { -webkit-text-size-adjust: 100%; }
  body { -webkit-tap-highlight-color: transparent; }
  .app-header { padding: 16px 0 4px; }
  .app-header h1 { font-size: 1.4rem; }
  .layout {
    gap: 14px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  }
  .column { padding: 14px; }

  /* Reorder for phones: calendar first (the centerpiece), then to-dos, then notes */
  .calendar-column { order: 1; }
  .todo-column     { order: 2; }
  .note-column     { order: 3; }

  /* 16px inputs prevent iOS from auto-zooming on focus */
  .todo-form input,
  .sticky-pad textarea { font-size: 16px; }
  .todo-form button { width: 44px; height: 44px; }  /* min comfortable tap size */

  .view-switch { width: 100%; }                      /* full-width segmented control */
  .view-switch button { flex: 1; padding: 11px 0; }
  .calendar-toolbar button { width: 44px; height: 44px; }
  .calendar-toolbar h2 { font-size: 1.05rem; }

  .weekday-row, .calendar-grid { gap: 4px; }
  .weekday-row { font-size: .6rem; }
  .day {
    min-height: 62px;
    padding: 4px;
    border-radius: 8px;
  }
  .calendar-grid.week-mode .day { min-height: 140px; }
  .day-num { font-size: .72rem; }
  .day-note { font-size: .64rem; padding: 4px 15px 4px 5px; }
  .day-note .note-del { font-size: .9rem; top: 0; right: 2px; }  /* easier to tap */

  /* bigger color swatches for touch */
  .swatch { width: 28px; height: 28px; }
  .note-colors { gap: 12px; }

  .save-state-btn,
  .share-board-btn,
  .create-note-btn { padding: 13px; font-size: .92rem; }  /* taller tap targets */

  .saved-row { padding: 0 12px 32px; }
  .saved-slots { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* very small phones */
@media (max-width: 380px) {
  .day { min-height: 54px; }
  .day-num { font-size: .68rem; }
  .saved-slots { grid-template-columns: 1fr 1fr; gap: 8px; }
}
