/* ------------------------------------------------------------------
   uug4na & linzhen: one pixel calendar, two moods.
   The pixel frame is drawn with hard box-shadows (no blur), which
   leaves the outer corners notched, the way 8-bit UI boxes look.
   Elements using the frame reserve room for it with margins.
------------------------------------------------------------------ */

:root {
  --font-display: 'Press Start 2P', 'Courier New', monospace;
  --font-body: 'Pixelify Sans', 'Trebuchet MS', sans-serif;
  --px: 4px;
}

/* uug4na: the night shift */
:root[data-theme='uug4na'] {
  --bg: #140b1f;
  --bg-check: #1a0f29;
  --panel: #22122f;
  --panel-hi: #2d1a3f;
  --panel-dim: #1b0e29;
  --ink: #090411;
  --line: #3b2452;
  --text: #efe3d0;
  --muted: #9d89b8;
  --accent: #c8102e;
  --on-accent: #fff2f2;
  --accent-2: #e9b44c;
  --focus: #e9b44c;
  --danger: #ff5c6c;
  --who-uug4na: #e0243f;
  --who-linzhen: #ff7ab6;
  --backdrop-a: rgba(6, 2, 10, 0.82);
  --backdrop-b: rgba(6, 2, 10, 0.66);
  --edge: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 16' shape-rendering='crispEdges'%3E%3Cg fill='%23c8102e'%3E%3Crect x='0' y='0' width='32' height='3'/%3E%3Crect x='2' y='3' width='4' height='5'/%3E%3Crect x='3' y='8' width='2' height='2'/%3E%3Crect x='11' y='3' width='4' height='2'/%3E%3Crect x='19' y='3' width='4' height='9'/%3E%3Crect x='20' y='12' width='2' height='3'/%3E%3Crect x='27' y='3' width='3' height='4'/%3E%3C/g%3E%3C/svg%3E");
  --edge-size: 32px 16px;
  --edge-height: 16px;
  color-scheme: dark;
}

/* linzhen: the day shift */
:root[data-theme='linzhen'] {
  --bg: #fff3f7;
  --bg-check: #ffe6ef;
  --panel: #ffffff;
  --panel-hi: #fff0f5;
  --panel-dim: #fff7fa;
  --ink: #4a2b3a;
  --line: #f3cfdd;
  --text: #4a2b3a;
  --muted: #a98b99;
  --accent: #ff6fa5;
  --on-accent: #ffffff;
  --accent-2: #ffd45f;
  --focus: #6cc3ff;
  --danger: #d9365a;
  --who-uug4na: #b3202c;
  --who-linzhen: #ff5c9a;
  --backdrop-a: rgba(74, 43, 58, 0.62);
  --backdrop-b: rgba(74, 43, 58, 0.48);
  --edge: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 8' shape-rendering='crispEdges'%3E%3Cg fill='%23ff6fa5'%3E%3Crect x='0' y='0' width='16' height='2'/%3E%3Crect x='1' y='2' width='14' height='2'/%3E%3Crect x='3' y='4' width='10' height='2'/%3E%3Crect x='5' y='6' width='6' height='2'/%3E%3C/g%3E%3C/svg%3E");
  --edge-size: 16px 8px;
  --edge-height: 8px;
  color-scheme: light;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  font: 400 17px/1.4 var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  background-image: repeating-conic-gradient(var(--bg-check) 0 25%, transparent 0 50%);
  background-size: 24px 24px;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

[hidden] {
  display: none !important;
}

.display {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.5;
}

.sprite {
  display: inline-flex;
  line-height: 0;
  flex: none;
}

.sprite svg {
  display: block;
}

/* --- the pixel frame -------------------------------------------- */

.px-panel,
.btn,
.field input,
.field textarea,
.thumb,
.theme-switch {
  --frame: var(--ink);
  --shade: var(--ink);
  box-shadow:
    0 calc(-1 * var(--px)) 0 var(--frame),
    0 var(--px) 0 var(--frame),
    calc(-1 * var(--px)) 0 0 var(--frame),
    var(--px) 0 0 var(--frame),
    calc(2 * var(--px)) var(--px) 0 var(--shade),
    var(--px) calc(2 * var(--px)) 0 var(--shade);
  margin: var(--px) calc(2 * var(--px)) calc(2 * var(--px)) var(--px);
}

.px-panel {
  background: var(--panel);
}

/* --- buttons ------------------------------------------------------ */

.btn {
  --px: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 14px;
  border: 0;
  font: 600 16px/1.3 var(--font-body);
  color: var(--text);
  background: var(--panel);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--panel-hi);
}

.btn:active {
  transform: translate(var(--px), var(--px));
  --shade: transparent;
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 86%, var(--on-accent));
}

.btn-danger {
  color: var(--danger);
  --frame: var(--danger);
}

.btn-icon {
  padding: 8px 10px;
}

.btn-small {
  font-size: 14px;
  padding: 4px 10px;
}

.btn-wide {
  width: calc(100% - 9px);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 5px;
}

/* --- top bar ------------------------------------------------------ */

.topbar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 28px;
  padding: 18px 24px 22px;
  background: var(--panel);
  border-bottom: 4px solid var(--ink);
  margin-bottom: var(--edge-height);
}

.topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: var(--edge-height);
  background: var(--edge) repeat-x;
  background-size: var(--edge-size);
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-sprite {
  color: var(--accent);
}

@media (prefers-reduced-motion: no-preference) {
  .brand-sprite {
    animation: bob 1.4s steps(1, end) infinite;
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.brand-title {
  font-size: 18px;
  line-height: 1.6;
  white-space: nowrap;
}

.brand-title .amp {
  color: var(--accent);
}

.topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
}

.whoami {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.whoami .sprite {
  color: var(--who);
}

/* --- theme toggle ------------------------------------------------- */

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.theme-opt {
  border: 0;
  background: none;
  padding: 4px 6px;
  font: 600 16px var(--font-body);
  color: var(--muted);
  cursor: pointer;
}

.theme-opt[aria-pressed='true'] {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
  text-decoration-color: var(--accent);
}

.theme-switch {
  --px: 3px;
  position: relative;
  width: 60px;
  height: 28px;
  border: 0;
  padding: 0;
  background: var(--bg);
  cursor: pointer;
}

.theme-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--accent);
  transition: transform 0.22s steps(3, end);
}

:root[data-theme='linzhen'] .theme-knob {
  transform: translateX(32px);
}

@media (prefers-reduced-motion: reduce) {
  .theme-knob {
    transition: none;
  }
}

/* --- login -------------------------------------------------------- */

.login-view {
  display: grid;
  place-items: center;
  padding: 48px 16px;
}

.login-box {
  width: min(380px, 100%);
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-box .display {
  font-size: 14px;
}

.login-sprite {
  color: var(--accent);
  align-self: flex-start;
}

/* --- forms -------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  min-width: 0;
}

.field input,
.field textarea {
  --px: 3px;
  --shade: transparent;
  width: auto;
  min-width: 0;
  border: 0;
  padding: 8px 10px;
  font: 400 18px/1.3 var(--font-body);
  color: var(--text);
  background: var(--bg);
}

.field textarea {
  resize: vertical;
}

.field input:focus-visible,
.field textarea:focus-visible {
  outline: none;
  --frame: var(--focus);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

@media (max-width: 420px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.form-error {
  color: var(--danger);
  font-weight: 600;
  min-height: 1.4em;
}

.form-error:empty {
  display: none;
}

/* --- app layout --------------------------------------------------- */

.app-view {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

.month-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  margin-bottom: 14px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.month-title {
  font-size: 15px;
  min-width: 15ch;
  text-align: center;
  padding: 0 8px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 8px 26px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- calendar grid ------------------------------------------------ */

.calendar {
  padding: 0;
}

.weekdays,
.grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  background: var(--line);
}

.weekdays {
  border-bottom: 2px solid var(--line);
}

.weekday {
  padding: 7px 0 5px;
  text-align: center;
  font: 700 13px var(--font-body);
  color: var(--muted);
  background: var(--panel);
}

.day {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-height: 98px;
  padding: 6px;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  background: var(--panel);
  cursor: pointer;
}

.day:hover {
  background: var(--panel-hi);
}

.day:focus-visible {
  outline-offset: -4px;
}

.day.out {
  background: var(--panel-dim);
  color: var(--muted);
}

.day-num {
  align-self: flex-start;
  font: 400 10px/1 var(--font-display);
  padding: 4px 4px 3px;
}

.day.today .day-num {
  background: var(--accent-2);
  color: var(--ink);
}

.chip {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 2px 5px 2px 4px;
  font: 500 13px/1.25 var(--font-body);
  color: var(--text);
  background: color-mix(in srgb, var(--who) 22%, var(--panel));
  border-left: 3px solid var(--who);
}

.chip .sprite {
  color: var(--who);
}

.chip span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.more {
  font-size: 12px;
  color: var(--muted);
  padding-left: 4px;
}

.dots {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  padding: 2px;
}

.dots .sprite {
  color: var(--who);
}

@media (max-width: 640px) {
  .day {
    min-height: 60px;
    padding: 4px;
    gap: 3px;
  }

  .chip,
  .more {
    display: none;
  }

  .dots {
    display: flex;
  }

  .brand-title {
    font-size: 12px;
  }

  .month-title {
    font-size: 11px;
    min-width: 13ch;
  }
}

/* --- idea box ----------------------------------------------------- */

.ideas {
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ideas .display {
  font-size: 12px;
}

.ideas-hint,
.empty {
  color: var(--muted);
}

.idea-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.idea {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 6px;
  border: 0;
  font: 500 17px/1.3 var(--font-body);
  color: inherit;
  text-align: left;
  background: none;
  cursor: pointer;
  border-left: 3px solid var(--who);
}

.idea:hover {
  background: var(--panel-hi);
}

.idea .sprite {
  color: var(--who);
}

.idea span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- dialogs ------------------------------------------------------ */

.dialog {
  --px: 4px;
  margin: auto;
  width: min(560px, calc(100vw - 40px));
  max-height: calc(100dvh - 48px);
  padding: 20px 22px 22px;
  border: 0;
  color: var(--text);
  background: var(--panel);
  overflow: auto;
}

.dialog::backdrop {
  background: repeating-conic-gradient(var(--backdrop-a) 0 25%, var(--backdrop-b) 0 50%);
  background-size: 8px 8px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.dialog-head .display {
  font-size: 13px;
  line-height: 1.7;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
}

.dialog-actions .spacer {
  flex: 1;
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.byline {
  color: var(--muted);
  font-size: 14px;
}

/* --- day sheet ---------------------------------------------------- */

.plan-list {
  display: flex;
  flex-direction: column;
}

.plan-row {
  padding: 8px 0;
  border-top: 2px solid var(--line);
}

.plan-row:first-child {
  border-top: 0;
}

.plan-open {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  width: 100%;
  padding: 6px 4px;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  cursor: pointer;
}

.plan-open:hover {
  background: var(--panel-hi);
}

.plan-open .sprite {
  color: var(--who);
  margin-top: 4px;
}

.plan-row-title {
  font-weight: 600;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.plan-row-time {
  color: var(--accent);
  font-weight: 700;
  margin-right: 8px;
}

.plan-row-note {
  grid-column: 2;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.plan-row-by {
  grid-column: 2;
  color: var(--muted);
  font-size: 14px;
}

.plan-row .thumbs {
  padding: 6px 0 2px 44px;
}

/* --- pictures ----------------------------------------------------- */

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.thumbs:empty {
  display: none;
}

.thumb {
  --px: 3px;
  position: relative;
  width: 76px;
  height: 76px;
  padding: 0;
  border: 0;
  background: var(--bg);
  cursor: zoom-in;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb.pending {
  --frame: var(--accent);
}

.thumb-remove {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: var(--ink);
  color: var(--on-accent);
  cursor: pointer;
}

.thumb-remove:hover {
  background: var(--danger);
}

.file-btn {
  align-self: flex-start;
}

.lightbox {
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100dvh;
  overflow: visible;
}

.lightbox::backdrop {
  background: repeating-conic-gradient(var(--backdrop-a) 0 25%, var(--backdrop-b) 0 50%);
  background-size: 8px 8px;
}

.lightbox img {
  display: block;
  max-width: calc(100vw - 40px);
  max-height: calc(100dvh - 60px);
  background: var(--panel);
}

.lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
}
