/* dumit.me — Infinite Watercolor Sketchbook Design System (Vanilla CSS, Light & Dark) */

* {
  box-sizing: border-box;
}

:root {
  --font-editorial: 'Newsreader', Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-stamp: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Monaco, monospace;
}

body.theme-light {
  --chrome-bg: #faf7f0;
  --chrome-border: rgba(164, 146, 122, 0.34);
  --chrome-fg: #261e16;
  --chrome-muted: #70604e;
  --chrome-subtle: #f0eadc;
  --btn-bg: #fffdf8;
  --btn-primary-bg: #2d2219;
  --btn-primary-fg: #fcf8f0;
  --panel-bg: rgba(254, 251, 246, 0.93);
  --panel-border: rgba(164, 146, 120, 0.56);
  --panel-shadow: 0 12px 32px rgba(68, 52, 34, 0.15);
  --input-bg: rgba(255, 254, 250, 0.92);
  --input-border: rgba(168, 150, 124, 0.55);
  --hover-tint: rgba(45, 34, 25, 0.06);
  --toast-bg: rgba(235, 245, 236, 0.96);
  --toast-border: #8db594;
  --toast-fg: #1d3a23;
  --ring-active-outer: #3d2f22;
  --ring-active-inner: #fcf9f2;
  --trail-kicker: #9d513b;
}

body.theme-dark {
  --chrome-bg: #1d1c1f;
  --chrome-border: rgba(218, 204, 182, 0.14);
  --chrome-fg: #f0e9de;
  --chrome-muted: #a69c8e;
  --chrome-subtle: #28262b;
  --btn-bg: #262429;
  --btn-primary-bg: #ece3d3;
  --btn-primary-fg: #1b1816;
  --panel-bg: rgba(31, 29, 33, 0.90);
  --panel-border: rgba(214, 200, 180, 0.18);
  --panel-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  --input-bg: rgba(18, 17, 20, 0.72);
  --input-border: rgba(214, 200, 180, 0.22);
  --hover-tint: rgba(255, 248, 236, 0.08);
  --toast-bg: rgba(26, 40, 30, 0.94);
  --toast-border: rgba(136, 192, 146, 0.36);
  --toast-fg: #d6f0db;
  --ring-active-outer: #ebe1cf;
  --ring-active-inner: #1f1d21;
  --trail-kicker: #de8e74;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--chrome-bg);
  color: var(--chrome-fg);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* --- Top Header Bar --- */
.top-bar {
  flex-shrink: 0;
  z-index: 40;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-border);
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.top-left,
.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-title {
  margin: 0;
  font-family: var(--font-editorial);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--chrome-fg);
}

.brand-sub {
  font-family: var(--font-stamp);
  font-size: 12px;
  color: var(--chrome-muted);
}

.segmented {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  border: 1px solid var(--chrome-border);
  background: var(--chrome-subtle);
  padding: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--chrome-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.seg-btn.active {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}

.top-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 9px;
  border: 1px solid var(--chrome-border);
  background: var(--btn-bg);
  color: var(--chrome-fg);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 140ms ease, background-color 140ms ease;
}

.top-btn:hover {
  opacity: 0.88;
}

.top-btn-subtle {
  color: var(--chrome-muted);
  font-family: var(--font-stamp);
}

/* --- Infinite Paper Viewport --- */
.desk-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background-repeat: repeat;
}

.desk-viewport.panning {
  cursor: grabbing;
}

body.theme-light .desk-viewport {
  background-color: #f3eee3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='240' height='240' fill='%23f3eee3'/%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='0.062'/%3E%3Ccircle cx='120' cy='120' r='0.95' fill='%238c7a62' opacity='0.15'/%3E%3C/svg%3E");
}

body.theme-dark .desk-viewport {
  background-color: #171619;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cfilter id='nd'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='240' height='240' fill='%23171619'/%3E%3Crect width='240' height='240' filter='url(%23nd)' opacity='0.07'/%3E%3Ccircle cx='120' cy='120' r='0.95' fill='%23e5d7c0' opacity='0.11'/%3E%3C/svg%3E");
}

.studio-light {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 10;
  transition: background 300ms ease;
}

body.theme-light .studio-light {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 254, 250, 0.30) 0%, transparent 56%),
    radial-gradient(ellipse at 50% 50%, transparent 56%, rgba(154, 138, 114, 0.16) 100%);
}

body.theme-dark .studio-light {
  background:
    radial-gradient(ellipse at 35% 24%, rgba(215, 198, 172, 0.045) 0%, transparent 58%),
    radial-gradient(ellipse at 50% 50%, transparent 48%, rgba(4, 4, 6, 0.44) 100%);
}

/* --- Unbounded World Layers --- */
.world-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: visible;
  transform-origin: 0 0;
  will-change: transform;
}

.infinite-svg {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
}

.cards-layer {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
}

/* --- Animated Ink Doodles --- */
@keyframes drawInk {
  from {
    stroke-dashoffset: 640;
    opacity: 0.25;
  }
  to {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

.doodle-fresh path,
.doodle-fresh circle,
.doodle-fresh polygon,
.doodle-fresh line,
.doodle-fresh rect,
.doodle-fresh ellipse,
.doodle-fresh polyline {
  stroke-dasharray: 640;
  animation: drawInk 1150ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.doodle-group {
  cursor: pointer;
  transition: opacity 180ms ease;
}

.doodle-group:hover {
  opacity: 1 !important;
}

/* --- Cards & Stickies --- */
.desk-card {
  position: absolute;
  padding: 16px;
  border-radius: 3px;
  user-select: none;
  touch-action: none;
  cursor: grab;
  transition: filter 180ms ease, opacity 220ms ease;
}

.vellum-blur {
  backdrop-filter: blur(4px) saturate(1.12);
  -webkit-backdrop-filter: blur(4px) saturate(1.12);
}

.watercolor-blur {
  backdrop-filter: blur(2px) saturate(1.08);
  -webkit-backdrop-filter: blur(2px) saturate(1.08);
}

.desk-card.dragging {
  cursor: grabbing;
  z-index: 95 !important;
  filter: drop-shadow(0 18px 26px rgba(32, 22, 12, 0.28));
}

.desk-card.dimmed {
  opacity: 0.25;
  filter: saturate(0.45);
}

.desk-card.trail-active {
  z-index: 80 !important;
  filter: drop-shadow(0 0 16px rgba(206, 138, 96, 0.5)) drop-shadow(0 10px 18px rgba(32, 22, 12, 0.22));
}

.desk-card.newly-dropped {
  animation: cardFloatIn 460ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cardFloatIn {
  0% {
    opacity: 0;
    transform: scale(1.08) translateY(-18px);
  }
  100% {
    opacity: 1;
  }
}

.card-paint-bg {
  position: absolute;
  inset: -11px;
  width: calc(100% + 22px);
  height: calc(100% + 22px);
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.card-content {
  position: relative;
  z-index: 3;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  padding-right: 14px;
}

.card-stamp {
  font-family: var(--font-stamp);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-title {
  margin: 0 0 6px;
  font-family: var(--font-editorial);
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.28;
}

.card-body {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.54;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-sticky-body {
  margin: 0 0 10px;
  font-family: var(--font-editorial);
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.5;
}

.card-url-chip {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-stamp);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-private-tag {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed;
  font-family: var(--font-stamp);
  font-size: 11.5px;
}

.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 24;
  cursor: pointer;
}

.edge-badge {
  cursor: pointer;
}

.edge-badge:hover {
  filter: brightness(0.96);
}

/* --- Floating Vellum UI Panels --- */
.vellum-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px) saturate(1.12);
  -webkit-backdrop-filter: blur(12px) saturate(1.12);
  border: 1px solid var(--panel-border);
  color: var(--chrome-fg);
  box-shadow: var(--panel-shadow);
}

.desk-legend {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-line {
  display: inline-block;
  width: 16px;
  border-top: 1.5px solid #6b5948;
}

.legend-line.dashed {
  border-top-style: dashed;
  border-color: #558060;
}

.legend-muted {
  color: var(--chrome-muted);
}

.zoom-controls {
  position: absolute;
  bottom: 20px;
  right: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 12px;
  font-size: 12px;
}

.icon-btn,
.zoom-readout,
.zoom-fit-btn,
.close-btn {
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 140ms ease;
}

.icon-btn {
  width: 28px;
  height: 28px;
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.zoom-readout,
.zoom-fit-btn {
  height: 28px;
  padding: 0 8px;
  font-family: var(--font-stamp);
  font-size: 12px;
}

.close-btn {
  padding: 4px 8px;
  font-size: 12px;
  color: var(--chrome-muted);
}

.icon-btn:hover,
.zoom-readout:hover,
.zoom-fit-btn:hover,
.close-btn:hover {
  background: var(--hover-tint);
}

.zoom-sep {
  width: 1px;
  height: 16px;
  background: var(--chrome-border);
  margin: 0 2px;
}

/* --- Toast --- */
.gardener-toast {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 45;
  max-width: 310px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12px;
  background: var(--toast-bg);
  border: 1px solid var(--toast-border);
  color: var(--toast-fg);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.gardener-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-heading {
  font-family: var(--font-stamp);
  font-weight: 500;
  margin-bottom: 3px;
}

.toast-body {
  line-height: 1.45;
}

/* --- Popover & Trail Bar --- */
.edge-popover {
  position: absolute;
  z-index: 50;
  width: 290px;
  padding: 14px;
  border-radius: 14px;
}

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

.badge-pill {
  font-family: var(--font-stamp);
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 9999px;
  white-space: nowrap;
}

.popover-reason {
  margin: 0 0 12px;
  font-family: var(--font-editorial);
  font-size: 14.5px;
  line-height: 1.4;
}

.popover-actions,
.edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.trail-bar {
  position: absolute;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: min(92%, 510px);
  padding: 14px 16px;
  border-radius: 16px;
}

.trail-kicker {
  font-family: var(--font-stamp);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--trail-kicker);
}

.trail-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- Inspector Drawer --- */
.inspector {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 92px;
  width: 380px;
  z-index: 50;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inspector-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--chrome-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inspector-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.meta-date {
  font-family: var(--font-stamp);
  font-size: 11.5px;
  color: var(--chrome-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ins-title {
  margin: 0 0 8px;
  font-family: var(--font-editorial);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
}

.ins-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-line;
  opacity: 0.92;
}

.ins-url-wrap {
  margin-top: 10px;
}

.ins-url-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-stamp);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid;
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ins-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.tag-chip {
  font-family: var(--font-stamp);
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid var(--chrome-border);
  background: var(--chrome-subtle);
  color: var(--chrome-muted);
}

.owner-controls-row {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
}

.ins-section {
  padding-top: 12px;
  border-top: 1px solid var(--chrome-border);
}

.section-label {
  font-family: var(--font-stamp);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--chrome-muted);
  margin-bottom: 8px;
}

.connections-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conn-btn {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--chrome-border);
  background: var(--chrome-subtle);
  color: var(--chrome-fg);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.conn-btn:hover {
  opacity: 0.9;
}

.sticky-form,
.ins-edit-form,
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sticky-input-row {
  display: flex;
  gap: 8px;
}

.field-input {
  width: 100%;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--chrome-fg);
  font-family: var(--font-sans);
  font-size: 12.5px;
  outline: none;
}

.field-input:focus {
  border-color: var(--chrome-muted);
}

.btn-primary {
  border: none;
  border-radius: 9px;
  padding: 7px 13px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary:hover {
  opacity: 0.9;
}

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

.btn-ghost {
  border: 1px solid var(--chrome-border);
  border-radius: 9px;
  padding: 6px 11px;
  background: transparent;
  color: var(--chrome-fg);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-ghost:hover {
  background: var(--hover-tint);
}

.btn-danger {
  color: #b84a39;
}

/* --- Bottom Capture Dock & Visitor Ribbon --- */
.capture-dock {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: min(94%, 700px);
  padding: 10px 14px;
  border-radius: 16px;
}

.capture-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toss-tag {
  font-family: var(--font-stamp);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--chrome-subtle);
  color: var(--chrome-muted);
  flex-shrink: 0;
}

.capture-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--chrome-fg);
  font-family: var(--font-sans);
  font-size: 13.5px;
  outline: none;
}

.pigment-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.pigment-dot {
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  border: 1.5px solid rgba(110, 96, 78, 0.34);
  cursor: pointer;
  transition: transform 130ms ease, box-shadow 130ms ease;
}

.pigment-dot:hover {
  transform: scale(1.12);
}

.pigment-dot.active {
  transform: scale(1.14);
  box-shadow: 0 0 0 2px var(--ring-active-inner), 0 0 0 3.5px var(--ring-active-outer);
}

.seed-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--chrome-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.visitor-ribbon {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 12px;
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Auth Modal --- */
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 70;
  background: rgba(16, 14, 12, 0.42);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-dialog {
  width: min(100%, 380px);
  padding: 18px;
  border-radius: 16px;
}

.auth-title {
  margin: 0;
  font-family: var(--font-editorial);
  font-size: 19px;
  font-weight: 600;
}

.auth-desc {
  margin: 0 0 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--chrome-muted);
}

.auth-error {
  margin: 0;
  font-size: 12px;
  color: #c24b3a;
}

/* --- Responsive Mobile Layout --- */
@media (max-width: 768px) {
  .brand-sub,
  .desk-legend,
  .toss-tag,
  .pigment-picker,
  .seed-toggle {
    display: none;
  }

  .inspector {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 78vh;
    border-radius: 18px 18px 0 0;
  }

  .zoom-controls {
    bottom: 84px;
    right: 10px;
  }
}
