@font-face {
  font-family: Literata;
  src: url("/fonts/literata.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Literata;
  src: url("/fonts/literata-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --desk: #e6e9ee;
  --desk-glow: #f9fbfe;
  --desk-line: rgba(96, 108, 128, 0.05);
  --paper: #f1f3f7;
  --sheet: #fbfcfe;
  --ink: #23272f;
  --ink-soft: #5c6572;
  --ink-faint: #939cab;
  --ink-hover: #333a45;
  --rule: rgba(96, 108, 128, 0.18);
  --edge: rgba(96, 108, 128, 0.26);
  --wash: rgba(96, 108, 128, 0.09);
  --shadow: rgba(34, 42, 56, 0.85);
  --veil: rgba(30, 38, 50, 0.34);
  --radius: 12px;
  --control: 2.6rem;
  --ok: #4f8a6a;
  --wait: #6b83ab;
  --bad: #a8524c;
  color-scheme: light;
}

.app[data-theme="gray"] {
  --paper: #3f444c;
  --sheet: #4a5059;
  --ink: #f0f2f5;
  --ink-soft: #c6ccd4;
  --ink-faint: #9aa2ac;
  --ink-hover: #d8dde3;
  --rule: rgba(232, 238, 246, 0.13);
  --edge: rgba(232, 238, 246, 0.22);
  --wash: rgba(232, 238, 246, 0.09);
  --shadow: rgba(0, 0, 0, 0.5);
  --veil: rgba(12, 15, 19, 0.48);
  --ok: #7fbc94;
  --wait: #a0b5d6;
  --bad: #e28f84;
}

.app[data-theme="carbon"] {
  --paper: #0d0f11;
  --sheet: #15181b;
  --ink: #e6e9ec;
  --ink-soft: #a9b1bb;
  --ink-faint: #6f7781;
  --ink-hover: #ccd2d9;
  --rule: rgba(220, 228, 238, 0.11);
  --edge: rgba(220, 228, 238, 0.19);
  --wash: rgba(220, 228, 238, 0.08);
  --shadow: rgba(0, 0, 0, 0.9);
  --veil: rgba(0, 0, 0, 0.62);
  --ok: #6fae87;
  --wait: #8fa3c7;
  --bad: #d4796f;
}

:root:has(.app[data-theme="gray"]) {
  --desk: #2e323a;
  --desk-glow: #454b55;
  --desk-line: rgba(232, 238, 246, 0.035);
  color-scheme: dark;
}

:root:has(.app[data-theme="carbon"]) {
  --desk: #050607;
  --desk-glow: #14171a;
  --desk-line: rgba(220, 228, 238, 0.03);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body,
#main {
  background-color: var(--desk);
  background-image:
    radial-gradient(120% 70% at 50% -10%, var(--desk-glow) 0%, transparent 62%),
    repeating-linear-gradient(0deg, var(--desk-line) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, var(--desk-line) 0 1px, transparent 1px 5px);
}

body {
  color: var(--ink);
  font-family: "Literata", ui-serif, Georgia, Palatino, serif;
  overscroll-behavior: none;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 44rem;
  margin: 0 auto;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--rule), 0 30px 70px -40px var(--shadow);
}

.top {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  height: 0;
  pointer-events: none;
}

.top.draggable {
  height: auto;
  pointer-events: auto;
  cursor: grab;
  user-select: none;
}

.brand {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: calc(0.5rem + env(safe-area-inset-top, 0px)) 0 0 0.85rem;
  padding: 0.32rem 0.7rem;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--sheet);
  color: inherit;
  cursor: pointer;
  font-family: "Literata", ui-serif, Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  box-shadow: 0 1px 1px var(--rule), 0 10px 22px -16px var(--shadow);
}

.dot {
  width: 0.46rem;
  height: 0.46rem;
  border-radius: 50%;
  background: var(--ink-faint);
}

.dot.synced {
  background: var(--ok);
}

.dot.connecting {
  background: var(--wait);
  animation: breathe 1.3s ease-in-out infinite;
}

.dot.offline {
  background: var(--bad);
}

@keyframes breathe {
  50% {
    opacity: 0.35;
  }
}

.act {
  min-height: var(--control);
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: transparent;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
  touch-action: manipulation;
}

.act:hover {
  background: var(--wash);
}

.seg {
  display: flex;
  gap: 0.35rem;
}

.seg .act {
  flex: 1;
  padding: 0.5rem 0.4rem;
}

.seg .act[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.feed {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 0.85rem 1.4rem;
}

.feed::before {
  content: "";
  margin-top: auto;
}

.empty {
  margin: auto;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-faint);
  font-family: "Literata", ui-serif, Georgia, Palatino, serif;
}

.empty p {
  margin: 0 0 0.3rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.empty .small {
  font-size: 0.86rem;
}

.small {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ink-faint);
}

.day {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0.9rem 0 0.15rem;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.day::before,
.day::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--edge), transparent);
}

.bubble {
  padding: 0.65rem 0.85rem 0.45rem;
  background: var(--sheet);
  border-radius: var(--radius);
  box-shadow: 0 1px 1px var(--rule), 0 10px 22px -16px var(--shadow);
  font-family: "Literata", ui-serif, Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 1.03rem;
  line-height: 1.5;
  animation: rise 0.16s ease-out;
}

.bubble:focus-within {
  box-shadow: 0 0 0 3px var(--edge), 0 10px 22px -16px var(--shadow);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.text {
  overflow-wrap: anywhere;
  cursor: text;
}

.text > :first-child {
  margin-top: 0;
}

.text > :last-child:not(hr) {
  margin-bottom: 0;
}

.text p {
  margin: 0 0 0.55rem;
}

.text h1,
.text h2,
.text h3,
.text h4,
.text h5,
.text h6 {
  margin: 0.85rem 0 0.4rem;
  font-weight: 600;
  line-height: 1.3;
}

.text h1 {
  font-size: 1.34em;
}

.text h2 {
  font-size: 1.2em;
}

.text h3 {
  font-size: 1.09em;
}

.text h4 {
  font-size: 1em;
}

.text h5 {
  font-size: 0.94em;
}

.text h6 {
  font-size: 0.9em;
  color: var(--ink-soft);
}

.text ul,
.text ol {
  margin: 0 0 0.55rem;
  padding-left: 1.25rem;
}

.text li {
  margin: 0.1rem 0;
}

.text li p {
  margin: 0;
}

.text li::marker {
  color: var(--ink-faint);
}

.text blockquote {
  margin: 0 0 0.55rem;
  padding: 0.05rem 0 0.05rem 0.75rem;
  border-left: 2px solid var(--edge);
  color: var(--ink-soft);
}

.text code {
  padding: 0.1em 0.3em;
  border-radius: 5px;
  background: var(--wash);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
}

.text pre {
  margin: 0 0 0.55rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius);
  background: var(--wash);
  overflow-x: auto;
}

.text pre code {
  padding: 0;
  background: none;
  font-size: 0.82em;
  line-height: 1.45;
}

.text a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--ink-faint);
  text-underline-offset: 2px;
}

.text a:hover {
  text-decoration-color: currentColor;
}

.text hr {
  margin: 0.85rem 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.text strong {
  font-weight: 600;
}

.text del {
  color: var(--ink-faint);
}

.meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.2rem;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.copy {
  display: grid;
  place-items: center;
  min-width: 2.4rem;
  min-height: var(--control);
  margin: -0.2rem -0.2rem -0.2rem auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-faint);
  opacity: 0.45;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.15s ease;
}

.copy:hover {
  opacity: 1;
  color: var(--ink);
}

.pin {
  display: grid;
  place-items: center;
  min-width: 2.4rem;
  min-height: var(--control);
  margin: -0.2rem 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-faint);
  opacity: 0.45;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.pin:hover {
  opacity: 1;
  color: var(--ink);
}

.pin.on {
  opacity: 1;
  color: var(--ink);
}

.del {
  display: grid;
  place-items: center;
  min-width: 2.4rem;
  min-height: var(--control);
  margin: -0.2rem -0.45rem -0.2rem 0;
  padding: 0;
  border: 0;
  background: none;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--ink-faint);
  opacity: 0.45;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.15s ease;
}

.del:hover {
  opacity: 1;
  color: var(--bad);
}

.edit {
  width: 100%;
  field-sizing: content;
  min-height: var(--control);
  padding: 0.1rem 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 1.03rem;
  line-height: 1.5;
  resize: none;
}

.edit:focus {
  outline: none;
}

.acts {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.3rem;
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding: 0.6rem 0.8rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
}

.pad {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  padding: 0.3rem;
  border: 1px solid var(--edge);
  border-radius: calc(var(--radius) + 6px);
  background: var(--sheet);
  box-shadow: 0 1px 1px var(--rule), 0 14px 30px -20px var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pad:focus-within {
  border-color: var(--ink-faint);
  box-shadow: 0 0 0 3px var(--wash), 0 14px 30px -20px var(--shadow);
}

.draft {
  flex: 1;
  field-sizing: content;
  min-height: var(--control);
  max-height: 9rem;
  padding: 0.45rem 0.5rem;
  border: 0;
  background: none;
  font-family: "Literata", ui-serif, Georgia, Palatino, serif;
  font-size: 1.02rem;
  line-height: 1.4;
  resize: none;
}

.draft:focus {
  outline: none;
}

.send {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: var(--control);
  height: var(--control);
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.send:hover:enabled {
  background: var(--ink-hover);
}

.send:active:enabled {
  transform: scale(0.94);
}

.send:disabled {
  opacity: 0.28;
  cursor: default;
}

.veil {
  position: fixed;
  inset: 0;
  z-index: 4;
  background: var(--veil);
  animation: fade 0.2s ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 5;
  max-width: 44rem;
  max-height: 92dvh;
  overflow-y: auto;
  margin: 0 auto;
  padding: 0.9rem 0.9rem calc(1rem + env(safe-area-inset-bottom, 0px));
  background: var(--sheet);
  border-top: 1px solid var(--edge);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -24px 44px -28px var(--shadow);
  animation: slide 0.2s ease-out;
}

.sheet:focus,
.sheet:focus-visible {
  outline: none;
}

@keyframes slide {
  from {
    transform: translateY(100%);
  }
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sheet h2 {
  margin: 0;
  font-family: "Literata", ui-serif, Georgia, Palatino, serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.x {
  display: grid;
  place-items: center;
  width: var(--control);
  height: var(--control);
  margin-right: -0.4rem;
  border: 0;
  border-radius: var(--radius);
  background: none;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  touch-action: manipulation;
}

.x:hover {
  background: var(--wash);
  color: var(--ink-soft);
}

.hint {
  margin: 0.9rem 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.notice {
  margin: 0.6rem 0 0.2rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bad) 7%, transparent);
}

.notice p {
  margin: 0 0 0.5rem;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.qr {
  display: block;
  width: 35%;
  height: auto;
  margin: 0.8rem auto 0;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--sheet);
  shape-rendering: crispEdges;
}

.sheet .row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.readout {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: var(--control);
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-overflow: ellipsis;
}

.readout:focus {
  outline: none;
  border-color: var(--ink-faint);
  box-shadow: 0 0 0 3px var(--wash);
}

.act.wide {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.5rem;
}

.act.warn {
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  color: var(--bad);
}

.act.warn:hover {
  background: color-mix(in srgb, var(--bad) 10%, transparent);
}

.toast {
  position: absolute;
  bottom: calc(100% + 0.6rem);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.4rem 0.3rem 0.95rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.78rem;
  box-shadow: 0 12px 28px -12px var(--shadow);
  transform: translateX(-50%);
  animation: toast-in 0.16s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
}

.toast .act {
  border-color: color-mix(in srgb, var(--paper) 30%, transparent);
  color: var(--paper);
}

.toast .act:hover {
  background: color-mix(in srgb, var(--paper) 14%, transparent);
}

.toast .act:focus-visible {
  outline-color: var(--paper);
}

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