:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --surface: #161616;
  --fg: #f5f5f5;
  --muted: #8a8a8a;
  --border: #2b2b2b;
  --birthday: #ffcb77;
  --vacation: #8ecae6;
  --rest: #a8d5a2;
  --holiday: #ff6b6b;
  --task: #e63946;
  --shift-morning: #c9b6e4;
  --shift-afternoon: #f4a261;
  --shift-night: #9a9a9a;
  --sticky-bg: #fdea6b;
  --sticky-fg: #3a3216;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --fg: #16171a;
  --muted: #6b6f76;
  --border: #dcdde0;
}

html[data-theme="sepia"] {
  color-scheme: light;
  --bg: #f4ecd8;
  --surface: #fbf3e1;
  --fg: #4a3826;
  --muted: #8a7256;
  --border: #d9c9a3;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 87.5%;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  color: var(--fg);
  font-family: "Montserrat", system-ui, sans-serif;
  font-weight: 200;
  padding: 1.5rem;
}

h1 {
  font-size: 1.3rem;
  font-weight: 200;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h2 {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.theme-toggle {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
}

.theme-toggle button {
  padding: 0.35rem 0.6rem;
  font-size: 0.7rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: min(320px, 100%);
  padding-top: 2.75rem;
}

.page {
  width: min(1120px, 100%);
  /* Positioning context for freely-dragged sticky notes (position: absolute,
     set inline once a note has a saved pos_x/pos_y) so they can float over
     any other section -- calendar, bookmarks, documents -- not just their
     own .sticky-notes box. */
  position: relative;
  /* Flex items default to min-width: auto, i.e. they refuse to shrink
     below their content's min-content size even when a smaller width is
     set above -- a wide-enough child (e.g. .bookmark-groups with several
     columns) would otherwise stretch .page, and with it the whole page,
     past the 1120px cap. */
  min-width: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input,
select,
textarea,
button {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
}

button {
  cursor: pointer;
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
}

button:hover {
  opacity: 0.8;
}

.bookmark-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  margin-bottom: 1rem;
}

.bookmark-form input {
  flex: 1;
  min-width: 120px;
}

.edit-mode-toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.edit-mode-toggle input {
  padding: 0;
}

.column-count-control {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.column-count-control select {
  padding: 0.3rem 0.5rem;
}

.bookmark-groups .edit-btn,
.bookmark-groups .delete-btn {
  display: none;
}

.offline-export-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.offline-export-row .hint {
  margin: 0;
}

.bookmark-groups.edit-mode .edit-btn,
.bookmark-groups.edit-mode .delete-btn {
  display: inline-flex;
}

.bookmark-import-export {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.bookmark-export {
  display: flex;
  gap: 0.5rem;
}

.secondary-btn {
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
  padding: 0.55rem 0.7rem;
  border-radius: 4px;
  text-decoration: none;
}

.secondary-btn:hover {
  opacity: 0.8;
}

.bookmark-import {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.bookmark-import input[type="file"] {
  padding: 0.4rem;
  max-width: 220px;
}

.error {
  color: var(--fg);
  font-size: 0.9rem;
  font-weight: 600;
  border-left: 2px solid var(--fg);
  padding-left: 0.6rem;
}

.bookmark-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bookmark-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: grab;
}

.bookmark-list li.empty {
  justify-content: center;
  color: var(--muted);
  cursor: default;
}

.bookmark-list li.dragging,
.bookmark-group.dragging {
  opacity: 0.4;
}

.bookmark-list a {
  color: var(--fg);
  text-decoration: none;
  /* min-width: 0 overrides the flex item default of min-width: auto, which
     otherwise sizes to the text's full intrinsic width and never lets it
     shrink enough for overflow: hidden/text-overflow to kick in. */
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bookmark-list a:hover {
  text-decoration: underline;
}

.bookmark-groups {
  display: grid;
  /* minmax(0, 1fr), not minmax(240px, 1fr): a fixed 240px floor is what was
     pushing 5-6 columns wider than the page and shoving everything else
     sideways. With 0 as the floor, columns always share the container's
     actual width evenly and just get narrower at higher column counts. */
  grid-template-columns: repeat(var(--bookmark-columns, 4), minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
  min-width: 0;
}

/* The chosen column count only applies above this width -- a phone screen
   is too narrow to keep more than one column readable, so it always falls
   back to a single column regardless of the saved preference. */
@media (max-width: 700px) {
  .bookmark-groups {
    grid-template-columns: 1fr;
  }
}

.bookmark-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: grab;
}

.bookmark-group-header h2 {
  margin: 0;
}

.category-reorder {
  display: flex;
  gap: 0.25rem;
}

.bookmark-more {
  margin-top: 0.5rem;
}

.bookmark-more summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.bookmark-more summary::-webkit-details-marker {
  display: none;
}

.bookmark-more summary::before {
  content: "▸";
  transition: transform 0.15s ease;
}

.bookmark-more[open] summary {
  display: none;
}

.bookmark-more summary:hover {
  color: var(--fg);
}

.bookmark-more .bookmark-list {
  margin-top: 0.5rem;
}

.bookmark-less-btn {
  display: none;
  margin-top: 0.5rem;
  background: transparent;
  border: none;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
  font-weight: inherit;
  font-size: 0.75rem;
  padding: 0;
  cursor: pointer;
}

.bookmark-less-btn:hover {
  color: var(--fg);
  opacity: 1;
}

.bookmark-more[open] .bookmark-less-btn {
  display: inline-block;
}

.bookmark-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  /* Never shrinks to make room for the ellipsis on a long name -- the name
     is what should give way, not the edit/delete buttons. */
  flex-shrink: 0;
}

.edit-btn,
.delete-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  line-height: 1.2;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.edit-btn:hover,
.delete-btn:hover {
  color: var(--fg);
  border-color: var(--fg);
  opacity: 1;
}

.edit-icon {
  display: inline-block;
  font-size: 0.65rem;
  transform: scaleX(-1);
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 1.5rem;
}

.modal-overlay:target {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal {
  position: relative;
  z-index: 1;
  width: min(360px, 100%);
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal h2 {
  margin: 0;
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal form textarea {
  min-height: 100px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.cancel-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
}

.cancel-btn:hover {
  color: var(--fg);
  border-color: var(--fg);
}

.modal p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.danger-btn {
  background: #c0392b;
  border-color: #c0392b;
  color: #fff;
}

.icon-buttons {
  display: flex;
  gap: 0.5rem;
}

.icon-buttons form {
  margin: 0;
  display: contents;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
}

.icon-btn:hover {
  border-color: var(--fg);
  opacity: 0.85;
}

.icon-sun {
  color: var(--birthday);
}

.icon-moon {
  color: var(--vacation);
}

.icon-sepia {
  color: #a9744f;
}

.logout-icon-btn {
  color: var(--holiday);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.6rem 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  font-size: 0.8rem;
  z-index: 10;
  animation: toast-fade-out 12s forwards;
}

.toast button {
  padding: 0.35rem 0.6rem;
  font-size: 0.7rem;
}

@keyframes toast-fade-out {
  0%, 90% {
    opacity: 1;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
  }
}

/* Calendar */

.calendar-section {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.calendar-nav {
  position: relative;
}

.calendar-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 1.1rem;
  height: 3rem;
}

.calendar-arrow-prev {
  left: -0.55rem;
}

.calendar-arrow-next {
  right: -0.55rem;
}

.arrow-tip {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.arrow-tip-left {
  border-right: 6px solid currentColor;
}

.arrow-tip-right {
  border-left: 6px solid currentColor;
}

.calendar-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.calendar {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem;
}

.calendar h3 {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
}

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

.day-header {
  font-size: 0.65rem;
  color: var(--muted);
  text-align: center;
  padding-bottom: 0.15rem;
}

.day {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1.6;
  font-size: 0.65rem;
  border-radius: 3px;
}

.past-day {
  color: var(--muted);
  opacity: 0.4;
}

.current-day {
  border: 1px solid var(--fg);
  font-weight: 700;
}

.day.vacation-day {
  background: color-mix(in srgb, var(--vacation) 30%, transparent);
}

.rest-day {
  background: color-mix(in srgb, var(--rest) 32%, transparent);
  box-shadow: inset 0 -2px 0 var(--rest);
}

.shift-morning {
  background: color-mix(in srgb, var(--shift-morning) 32%, transparent);
  box-shadow: inset 0 -2px 0 var(--shift-morning);
}

.shift-afternoon {
  background: color-mix(in srgb, var(--shift-afternoon) 32%, transparent);
  box-shadow: inset 0 -2px 0 var(--shift-afternoon);
}

.shift-night {
  background: color-mix(in srgb, var(--shift-night) 32%, transparent);
  box-shadow: inset 0 -2px 0 var(--shift-night);
}

.holiday-day {
  color: var(--holiday);
  font-weight: 700;
}

.day.birthday-day::after {
  content: "🎉";
  margin-left: 1px;
  font-size: 0.5rem;
  line-height: 1;
}

.task-marker {
  display: inline-block;
  width: 0.42rem;
  height: 0.42rem;
  margin-left: 2px;
  border-radius: 50%;
  background: var(--task);
}

/* A task title with an emoji shows that instead of the plain dot -- reset
   the dot's size/shape/background so only the emoji glyph renders. */
.task-marker-emoji {
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  font-size: 0.85rem;
  line-height: 1;
  vertical-align: middle;
}

.calendar-legend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-top: 0.75rem;
}

.calendar-legend-row > .calendar-settings {
  margin-top: 0;
  flex-shrink: 0;
  order: -1;
}

.calendar-legend-row > .calendar-settings[open] {
  flex-basis: 100%;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.legend-swatch.birthday-day {
  width: auto;
  height: auto;
  background: transparent;
  border: none;
  font-size: 0.9rem;
}

.legend-swatch.birthday-day::before {
  content: "🎉";
}

.legend-swatch.holiday-day {
  background: color-mix(in srgb, var(--holiday) 32%, transparent);
  box-shadow: inset 0 -2px 0 var(--holiday);
  border-color: transparent;
}

.legend-swatch.vacation-day {
  background: color-mix(in srgb, var(--vacation) 65%, transparent);
  border-color: transparent;
}

.legend-swatch.rest-day {
  background: color-mix(in srgb, var(--rest) 32%, transparent);
  box-shadow: inset 0 -2px 0 var(--rest);
  border-color: transparent;
}

.legend-swatch.shift-morning {
  background: color-mix(in srgb, var(--shift-morning) 32%, transparent);
  box-shadow: inset 0 -2px 0 var(--shift-morning);
  border-color: transparent;
}

.legend-swatch.shift-afternoon {
  background: color-mix(in srgb, var(--shift-afternoon) 32%, transparent);
  box-shadow: inset 0 -2px 0 var(--shift-afternoon);
  border-color: transparent;
}

.legend-swatch.shift-night {
  background: color-mix(in srgb, var(--shift-night) 32%, transparent);
  box-shadow: inset 0 -2px 0 var(--shift-night);
  border-color: transparent;
}

.legend-swatch.current-day {
  background: transparent;
  border-color: var(--fg);
}

.legend-task-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--task);
}

.calendar-settings {
  margin-top: 1rem;
}

.calendar-settings summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font: inherit;
  padding: 0.55rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
  width: fit-content;
}

.calendar-settings summary::-webkit-details-marker {
  display: none;
}

.calendar-settings summary::before {
  content: "▸";
  color: var(--muted);
  transition: transform 0.15s ease;
}

.calendar-settings[open] summary::before {
  transform: rotate(90deg);
}

.calendar-settings summary:hover {
  border-color: var(--fg);
}

.calendar-manage {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}

.manage-card {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem;
}

.manage-card h2 {
  margin: 0 0 0.5rem;
}

.hint {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.calendar-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.date-fields {
  display: flex;
  gap: 0.5rem;
}

.shift-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

.checkbox-label input {
  width: auto;
}

.date-fields input {
  width: 5rem;
}

.date-fields select {
  flex: 1;
}

.calendar-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
  max-height: 180px;
  overflow-y: auto;
}

.calendar-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.calendar-list li.empty {
  justify-content: center;
  color: var(--muted);
}

.document-list li:not(.empty) {
  cursor: grab;
}

.document-list li.dragging {
  opacity: 0.4;
}

/* Sticky notes */

.notes-documents-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.notes-documents-row .calendar-settings {
  margin-top: 0;
}

.sticky-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
}

.sticky-note {
  position: relative;
  width: 150px;
  min-height: 130px;
  padding: 0.9rem 0.7rem 0.6rem;
  background: var(--sticky-bg);
  color: var(--sticky-fg);
  border-radius: 2px;
  box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.3);
  /* Falls back to whichever nth-child rule below applies; a note with a
     user-chosen rotation gets --note-rotation set inline, which (being
     inline) always wins over those class rules. */
  transform: rotate(var(--note-rotation, 0deg));
  transition: transform 0.15s ease;
  /* Above the page's normal-flow content (calendar, bookmarks, documents)
     so a freely-dragged note (position: absolute, see .page) can be dropped
     on top of any of it; still below the modal overlay's z-index: 20. */
  z-index: 5;
  /* Required for the native resize handle (see .resizable) to render at all;
     harmless otherwise since content already wraps/clips within the box. */
  overflow: hidden;
}

/* Toggled by JS only while a note's edit form is open -- gives the note a
   native, textarea-style resize handle in its bottom-right corner. Gated to
   edit mode (rather than always-on) so it never fights the note's own
   draggable="true" position-dragging in view mode; JS also flips draggable
   to "false" for the same reason while this class is present, see drag.js. */
.sticky-note.resizable {
  resize: both;
  /* Mirrors STICKY_NOTE_SIZE_MIN/MAX in main.py -- keep in sync. */
  min-width: 90px;
  min-height: 90px;
  max-width: 220px;
  max-height: 220px;
}

/* Only real notes (data-id) are drag targets -- excludes the "add note" box,
   which reuses .sticky-note for its looks but isn't draggable. */
.sticky-note[data-id] {
  cursor: grab;
}

/* Stops the browser from scrolling the page on a touch-drag so drag.js's
   pointer-based fallback (native HTML5 drag-and-drop has no touch equivalent)
   gets the gesture instead. Keyed off draggable="true" rather than [data-id]
   so it's automatically lifted while a note is being edited/resized, when JS
   flips draggable to "false" -- otherwise scrolling/typing in the textarea
   would be blocked too. */
.sticky-note[draggable="true"] {
  touch-action: none;
}

.sticky-note.dragging {
  opacity: 0.4;
}

.sticky-notes .sticky-note:nth-child(3n+1) {
  --note-rotation: -2.5deg;
}

.sticky-notes .sticky-note:nth-child(3n+2) {
  --note-rotation: 1.5deg;
}

.sticky-notes .sticky-note:nth-child(3n+3) {
  --note-rotation: -1deg;
}

.sticky-note:hover {
  transform: rotate(0deg) scale(1.03);
  z-index: 6;
}

/* Named palette, chosen via the swatches in the edit form. Yellow is the
   default (theme's base --sticky-bg/--sticky-fg), so it needs no override. */
.sticky-note[data-color="pink"] {
  --sticky-bg: #f6a6c1;
  --sticky-fg: #4a1f30;
}

.sticky-note[data-color="blue"] {
  --sticky-bg: #a8d8f0;
  --sticky-fg: #1c3a4a;
}

.sticky-note[data-color="green"] {
  --sticky-bg: #b8e0a8;
  --sticky-fg: #234a1f;
}

.sticky-note[data-color="orange"] {
  --sticky-bg: #f7c07a;
  --sticky-fg: #5c3a10;
}

.sticky-note[data-color="purple"] {
  --sticky-bg: #cbaee0;
  --sticky-fg: #3a1f5c;
}

.sticky-note-style-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.sticky-note-colors {
  display: flex;
  gap: 0.3rem;
}

.sticky-note-color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.25);
  padding: 0;
  cursor: pointer;
}

.sticky-note-color-yellow {
  background: #fdea6b;
}

.sticky-note-color-pink {
  background: #f6a6c1;
}

.sticky-note-color-blue {
  background: #a8d8f0;
}

.sticky-note-color-green {
  background: #b8e0a8;
}

.sticky-note-color-orange {
  background: #f7c07a;
}

.sticky-note-color-purple {
  background: #cbaee0;
}

.sticky-note-rotate {
  display: flex;
  gap: 0.3rem;
}

.sticky-note-rotate-btn {
  background: transparent;
  border: none;
  color: var(--sticky-fg);
  opacity: 0.6;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.sticky-note-rotate-btn:hover {
  opacity: 1;
}

.sticky-note p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  font-weight: 400;
  white-space: pre-wrap;
  word-break: break-word;
  /* Otherwise a touch-drag's long-press-ish start triggers the browser's own
     text-selection loupe before drag.js's pointer handler gets a chance to
     move the note. */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.sticky-note-actions {
  position: absolute;
  top: 0.2rem;
  right: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.sticky-note-actions form {
  margin: 0;
}

.sticky-note-edit,
.sticky-note-delete {
  background: transparent;
  border: none;
  color: var(--sticky-fg);
  opacity: 0.5;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.sticky-note-delete {
  font-size: 0.9rem;
}

.sticky-note-edit {
  font-size: 0.7rem;
}

.sticky-note-edit:hover,
.sticky-note-delete:hover {
  opacity: 1;
}

.sticky-note-edit-form {
  display: none;
}

.sticky-note-edit-form:target,
.sticky-note-edit-form.editing {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  /* Without an explicit height the form only takes up as much vertical
     space as its content needs, so the color/rotate controls and Save/Cancel
     stay pinned right under the textarea instead of tracking the note's box
     as it's resized -- growing the note left them stranded partway down with
     empty space below, shrinking it clipped them under overflow: hidden.
     Filling the note's full (resized) height lets the column's flex:1
     textarea absorb the size change so the controls stay pinned to the
     bottom edge. */
  height: 100%;
  box-sizing: border-box;
}

.sticky-note-edit-form:target + .sticky-note-view,
.sticky-note-edit-form.editing + .sticky-note-view {
  display: none;
}

.sticky-note-edit-form textarea {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  padding: 0;
  color: var(--sticky-fg);
  font-size: 0.8rem;
  font-family: inherit;
  min-height: 70px;
}

.sticky-note-edit-form textarea:focus {
  outline: none;
}

.sticky-note-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.sticky-note-edit-actions a,
.sticky-note-edit-actions button {
  background: transparent;
  border: none;
  color: var(--sticky-fg);
  font-size: 0.7rem;
  padding: 0;
  text-decoration: none;
  opacity: 0.7;
  cursor: pointer;
}

.sticky-note-edit-actions button {
  font-weight: 600;
}

.sticky-note-edit-actions a:hover,
.sticky-note-edit-actions button:hover {
  opacity: 1;
  text-decoration: underline;
}

.sticky-note-add {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: transparent;
  border: 1px dashed var(--border);
  box-shadow: none;
}

.sticky-note-add textarea {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  padding: 0;
  color: var(--fg);
  font-size: 0.8rem;
  min-height: 70px;
}

.sticky-note-add button {
  align-self: flex-end;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.7rem;
}

#sticky-notes-settings .sticky-notes {
  margin-top: 0.75rem;
}

/* Photos (Polaroid-style frames) */

.photos {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
}

.photo-frame {
  position: relative;
  width: 150px;
  padding: 10px 10px 32px;
  background: #fdfdfa;
  border-radius: 2px;
  box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.35);
  /* Falls back to whichever nth-child rule below applies; a photo with a
     user-chosen rotation gets --photo-rotation set inline, which (being
     inline) always wins over those class rules -- same trick as .sticky-note. */
  transform: rotate(var(--photo-rotation, 0deg));
  transition: transform 0.15s ease;
  z-index: 5;
}

.photo-frame[data-id] {
  cursor: grab;
}

/* Same touch-drag fallback as .sticky-note above -- photos have no edit mode
   to gate around, so this is unconditional. */
.photo-frame[draggable="true"] {
  touch-action: none;
}

.photo-frame.dragging {
  opacity: 0.4;
}

.photos .photo-frame:nth-child(3n+1) {
  --photo-rotation: -3deg;
}

.photos .photo-frame:nth-child(3n+2) {
  --photo-rotation: 2deg;
}

.photos .photo-frame:nth-child(3n+3) {
  --photo-rotation: -1.5deg;
}

.photo-frame:hover {
  transform: rotate(0deg) scale(1.03);
  z-index: 6;
}

.photo-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #111;
  /* Otherwise a touch-drag's long-press-ish start triggers the browser's own
     "save/share image" callout or text-selection loupe before drag.js's
     pointer handler gets a chance to move the photo. */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.photo-frame-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.photo-frame:hover .photo-frame-actions,
.photo-frame:focus-within .photo-frame-actions {
  opacity: 1;
}

.photo-frame-actions form {
  margin: 0;
}

.photo-frame-rotate-btn,
.photo-frame-delete {
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  line-height: 1;
  font-size: 0.7rem;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.photo-frame-rotate-btn:hover,
.photo-frame-delete:hover {
  background: rgba(0, 0, 0, 0.8);
}

.photo-frame-add {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.5rem;
  min-height: 150px;
  background: transparent;
  border: 1px dashed var(--border);
  box-shadow: none;
}

.photo-frame-add input[type="file"] {
  max-width: 100%;
  padding: 0.4rem;
  font-size: 0.65rem;
  color: var(--fg);
}

.photo-frame-add button {
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.7rem;
}

#photos-settings .photos {
  margin-top: 0.75rem;
}

/* Instant-print entrance: a freshly uploaded photo slides down out of a
   "slot" and fades in, like a print easing out of an instant camera. Only
   applied by JS (see drag.js) to a photo that wasn't in the page before the
   upload -- never replayed on a plain reload. */
@keyframes photo-eject {
  from {
    transform: translateY(-65%) rotate(var(--photo-rotation, 0deg));
    opacity: 0;
  }
  to {
    transform: translateY(0) rotate(var(--photo-rotation, 0deg));
    opacity: 1;
  }
}

.photo-frame.photo-frame-new {
  animation: photo-eject 0.6s ease-out;
}
