:root {
  --dot-bg: black;
  --dot-color: white;
  --dot-size: 1px;
  --dot-space: 22px;
  --ink: #171719;
  --muted: #696d75;
  --paper: #f8f9fb;
  --paper-soft: #eef1f5;
  --line: #dfe3e8;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-dark: rgba(12, 12, 14, 0.86);
  --rose: #d7194b;
  --rose-dark: #a80f35;
  --amber: #c79013;
  --blue: #2364d8;
  --danger: #b71d33;
  --border: rgba(23, 23, 25, 0.12);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  height: 100vh;
  height: 100svh;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    linear-gradient(90deg, var(--dot-bg) calc(var(--dot-space) - var(--dot-size)), transparent 1%) center / var(--dot-space) var(--dot-space),
    linear-gradient(var(--dot-bg) calc(var(--dot-space) - var(--dot-size)), transparent 1%) center / var(--dot-space) var(--dot-space),
    var(--dot-color);
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(23, 23, 25, 0.15);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 12px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

input:focus,
textarea:focus {
  border-color: rgba(215, 25, 75, 0.7);
  box-shadow: 0 0 0 3px rgba(215, 25, 75, 0.13);
}

.is-hidden {
  display: none !important;
}

.auth-screen {
  width: min(100%, 520px);
  height: 100vh;
  height: 100svh;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

.login-card {
  width: min(100%, 390px);
  display: grid;
  gap: 16px;
  padding: 22px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-kicker,
.app-kicker,
.sheet-kicker {
  margin: 0 0 3px;
  color: var(--rose);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-card h1,
.app-header h1,
.sheet-header h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

.login-card h1 {
  font-size: 2.1rem;
}

.login-card label,
.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.remember-line {
  justify-content: start;
}

.primary-button,
.text-button,
.danger-button,
.icon-button,
.flip-button,
.date-pill,
.tab-button,
.action-link {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.primary-button {
  min-height: 46px;
  padding: 12px 16px;
  color: #fff;
  background: linear-gradient(180deg, var(--rose), var(--rose-dark));
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(168, 15, 53, 0.24);
}

.primary-button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.danger-button {
  min-height: 44px;
  padding: 11px 14px;
  color: #fff;
  background: var(--danger);
  font-weight: 800;
}

.text-button {
  min-height: 42px;
  padding: 10px 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-weight: 800;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--rose);
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
}

.icon-button.light {
  color: var(--ink);
  background: #eef1f5;
}

.form-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}

.app-shell {
  width: min(100%, 520px);
  height: 100vh;
  height: 100svh;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding:
    max(8px, env(safe-area-inset-top))
    10px
    calc(96px + env(safe-area-inset-bottom));
}

.app-header {
  flex: 0 0 auto;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 -10px;
  padding: 10px 10px 9px;
  background: rgba(0, 0, 0, 0.82);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.app-header h1 {
  color: #fff;
  font-size: 1.55rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 11px 0 10px;
}

.date-pill {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 9px 11px;
  color: #fff;
  background: var(--panel-dark);
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-align: left;
}

.date-pill span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.date-pill strong {
  font-size: 0.92rem;
}

.sync-text {
  min-width: 94px;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.view-host {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-width: none;
  overscroll-behavior: contain;
  opacity: 1;
  transform: translateX(0) scale(1);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
}

.view-host::-webkit-scrollbar {
  display: none;
}

.view-host.is-switching {
  opacity: 0;
  pointer-events: none;
  transform: translateX(6px) scale(0.997);
}

.week-toolbar,
.calendar-toolbar,
.notes-toolbar {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 9px;
  margin: 4px 0 12px;
}

.notes-toolbar {
  grid-template-columns: 1fr auto;
}

.flip-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 1.45rem;
  font-weight: 900;
}

.week-title,
.calendar-title,
.notes-title {
  min-width: 0;
  color: #fff;
  text-align: center;
}

.notes-title {
  text-align: left;
}

.week-title strong,
.calendar-title strong,
.notes-title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}

.week-title span,
.calendar-title span,
.notes-title span {
  display: block;
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.76rem;
  font-weight: 800;
}

.planner-book {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
  perspective: 1000px;
  transform-origin: center;
}

.planner-view {
  min-height: 100%;
  overflow: visible;
}

.planner-book.is-flipping-next {
  animation: flipNext 0.28s ease;
}

.planner-book.is-flipping-prev {
  animation: flipPrev 0.28s ease;
}

.page-column {
  display: grid;
  align-content: start;
  gap: 8px;
}

.spine {
  position: relative;
  margin: 6px 0;
  background:
    radial-gradient(circle at center, transparent 0 5px, #08080a 6px 8px, transparent 9px) center top / 22px 26px repeat-y;
}

.spine::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 50%;
  width: 2px;
  background: rgba(0, 0, 0, 0.48);
  transform: translateX(-50%);
}

.day-card {
  width: 100%;
  min-height: clamp(82px, calc((100svh - 344px) / 4), 128px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  padding: 9px 9px 7px;
  color: var(--ink);
  text-align: left;
  background:
    repeating-linear-gradient(to bottom, transparent 0 24px, var(--line) 25px 26px),
    linear-gradient(180deg, #fbfcfe, var(--paper));
  border: 1px solid rgba(23, 23, 25, 0.08);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.day-card.is-today {
  border-color: rgba(215, 25, 75, 0.72);
  box-shadow:
    0 0 0 2px rgba(215, 25, 75, 0.18),
    0 8px 22px rgba(0, 0, 0, 0.16);
}

.day-card:active,
.calendar-day:active,
.note-card:active,
.entry-button:active,
.primary-button:active,
.danger-button:active,
.text-button:active,
.icon-button:active,
.flip-button:active,
.action-link:active {
  transform: scale(0.98);
}

.day-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
}

.weekday {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.day-number {
  display: block;
  margin-top: 1px;
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
}

.count-badge {
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  background: var(--rose);
  box-shadow: 0 5px 12px rgba(168, 15, 53, 0.2);
  font-size: 0.76rem;
  font-weight: 900;
}

.count-badge.empty {
  background: rgba(23, 23, 25, 0.15);
  color: rgba(23, 23, 25, 0.56);
}

.day-lines {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 4px;
  padding-top: 2px;
}

.appointment-line {
  min-width: 0;
  color: #050507;
  overflow: visible;
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.24;
  text-overflow: initial;
  white-space: normal;
  overflow-wrap: anywhere;
}

.appointment-line.done {
  color: rgba(23, 23, 25, 0.46);
  text-decoration: line-through;
}

.appointment-line strong {
  font-weight: 950;
}

.appointment-line small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.more-line,
.empty-line {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

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

.weekday-name {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.calendar-day {
  min-height: 56px;
  display: grid;
  align-content: space-between;
  gap: 4px;
  padding: 7px 6px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid rgba(23, 23, 25, 0.09);
  border-radius: var(--radius);
  text-align: left;
}

.calendar-day.outside {
  opacity: 0.42;
}

.calendar-day.is-today {
  border-color: var(--rose);
}

.calendar-day.is-selected {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.calendar-day strong {
  font-size: 0.88rem;
  line-height: 1;
}

.calendar-day span {
  justify-self: start;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  color: #fff;
  background: var(--rose);
  font-size: 0.67rem;
  font-weight: 900;
}

.calendar-day.is-selected span {
  background: rgba(255, 255, 255, 0.22);
}

.selected-day,
.notes-list,
.day-sheet-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.selected-day-header,
.empty-state {
  color: #fff;
}

.selected-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.selected-day-header h2,
.notes-title h2 {
  margin: 0;
  font-size: 1.05rem;
}

.action-link {
  min-height: 38px;
  padding: 9px 11px;
  color: #fff;
  background: linear-gradient(180deg, var(--rose), var(--rose-dark));
  box-shadow: 0 8px 18px rgba(168, 15, 53, 0.2);
  font-size: 0.85rem;
  font-weight: 900;
}

.entry-button,
.note-card,
.paper-preview {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 11px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  text-align: left;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
}

.paper-preview {
  min-height: 128px;
  align-content: start;
  background:
    repeating-linear-gradient(to bottom, transparent 0 25px, var(--line) 26px 27px),
    linear-gradient(180deg, #fbfcfe, var(--paper));
}

.paper-preview.empty {
  place-items: center;
  color: var(--muted);
  font-weight: 900;
}

.entry-button {
  grid-template-columns: minmax(88px, auto) minmax(0, 1fr);
  column-gap: 12px;
  align-items: start;
}

.entry-time {
  color: var(--rose);
  font-size: 0.92rem;
  font-weight: 950;
  white-space: nowrap;
}

.entry-time.no-time {
  font-size: 0.78rem;
}

.entry-main strong,
.note-card strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.2;
}

.entry-main span,
.note-card span,
.note-card p {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
}

.entry-main p,
.note-card p {
  margin: 3px 0 0;
  line-height: 1.35;
  white-space: pre-wrap;
}

.entry-button.done .entry-main strong {
  color: rgba(23, 23, 25, 0.48);
  text-decoration: line-through;
}

.note-card.pinned {
  border-color: rgba(199, 144, 19, 0.45);
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.empty-state {
  margin: 16px 0;
  padding: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.24);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  align-items: end;
  padding: 16px 10px 0;
  background: rgba(0, 0, 0, 0.64);
}

.sheet {
  width: min(100%, 520px);
  max-height: calc(100svh - 22px);
  margin: 0 auto;
  display: grid;
  gap: 15px;
  overflow: auto;
  padding:
    17px
    14px
    calc(18px + env(safe-area-inset-bottom));
  color: var(--ink);
  background: #fff;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.34);
}

#daySheet .sheet {
  height: min(100%, calc(100svh - 22px));
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

#daySheetBody {
  min-height: 0;
  display: grid;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.sheet-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.save-icon-button img {
  width: 21px;
  height: 21px;
  display: block;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.icon-button.save-icon-button {
  background: var(--rose);
  color: #fff;
  box-shadow: 0 8px 18px rgba(168, 15, 53, 0.22);
}

.sheet-header h2 {
  font-size: 1.35rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.form-grid .full,
.check-line.full {
  grid-column: 1 / -1;
}

.check-line {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px !important;
  color: var(--ink) !important;
}

.check-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--rose);
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sheet-actions.single-action {
  grid-template-columns: 1fr;
}

.day-page-form {
  min-height: 0;
  display: grid;
  gap: 12px;
}

.day-page-textarea {
  height: 100%;
  min-height: 0;
  border: 1px solid rgba(23, 23, 25, 0.1);
  background:
    linear-gradient(to bottom, transparent 31px, var(--line) 31px) 0 7px / 100% 32px repeat-y,
    linear-gradient(180deg, #fbfcfe, var(--paper));
  line-height: 32px;
  padding: 7px 12px 10px;
  resize: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  z-index: 80;
  max-width: min(92vw, 460px);
  padding: 10px 12px;
  color: #fff;
  background: rgba(16, 16, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.bottom-tabs {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 30;
  width: min(calc(100% - 28px), 492px);
  height: 82px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 0 12px;
  overflow: visible;
  background: rgba(28, 28, 29, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateX(-50%);
}

.tab-button {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-rows: 50px 18px;
  place-items: center;
  gap: 0;
  min-height: 82px;
  padding: 0;
  color: rgba(255, 255, 255, 0.58);
  background: transparent;
  font-size: 0.68rem;
  font-weight: 900;
  transition:
    color 0.2s ease,
    transform 0.2s ease;
}

.tab-button.is-active {
  color: var(--rose);
  background: transparent;
}

.tab-icon {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  line-height: 1;
  border-radius: 50%;
  transition:
    width 0.18s ease,
    height 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.tab-icon img {
  width: 24px;
  height: 24px;
  display: block;
  object-fit: contain;
  transition:
    filter 0.18s ease,
    transform 0.18s ease,
    width 0.18s ease,
    height 0.18s ease;
}

.tab-button > span:last-child {
  position: relative;
  z-index: 2;
  line-height: 1;
  transition:
    color 0.2s ease,
    transform 0.24s ease;
}

.tab-button.is-active .tab-icon {
  width: 68px;
  height: 68px;
  align-self: start;
  margin-top: 7px;
  background: #fff;
  box-shadow: 0 7px 14px rgba(0, 0, 0, 0.24);
  transform: translateY(0);
}

.tab-button.is-active .tab-icon img {
  width: 24px;
  height: 24px;
  transform: translateY(-7px);
  filter: brightness(0) saturate(100%) invert(16%) sepia(90%) saturate(3975%) hue-rotate(334deg) brightness(91%) contrast(95%);
}

.tab-button.is-active > span:last-child {
  color: var(--rose);
  font-size: 0.61rem;
  transform: translateY(0);
}

@keyframes flipNext {
  from {
    opacity: 0.68;
    transform: translateX(16px) rotateY(-7deg);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotateY(0);
  }
}

@keyframes flipPrev {
  from {
    opacity: 0.68;
    transform: translateX(-16px) rotateY(7deg);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotateY(0);
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding-left: 7px;
    padding-right: 7px;
  }

  .app-header {
    margin-left: -7px;
    margin-right: -7px;
    padding-left: 7px;
    padding-right: 7px;
  }

  .day-card {
    padding: 8px 7px 6px;
  }

  .appointment-line {
    font-size: 0.78rem;
  }

  .planner-book {
    grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr);
  }

  .spine {
    background-size: 18px 25px;
  }

  .calendar-day {
    min-height: 50px;
    padding: 6px 5px;
  }
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 18px;
  }

  .app-header {
    border-radius: var(--radius);
    margin: 0 0 12px;
    padding: 12px;
  }

  .sheet-backdrop {
    align-items: center;
    padding: 24px;
  }

  .sheet {
    border-radius: 12px;
    padding-bottom: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
