:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #edf5f2;
  --ink: #19242a;
  --muted: #637177;
  --line: #d8e0dd;
  --accent: #217a73;
  --accent-strong: #14534f;
  --coral: #d76a5f;
  --shadow: 0 18px 42px rgba(20, 40, 45, 0.12);
  --radius: 8px;
  color-scheme: light;
  font-family:
    Inter, Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", system-ui,
    -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(25, 36, 42, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(25, 36, 42, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
}

button,
input,
textarea {
  font: inherit;
  min-width: 0;
}

button,
label[for] {
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: progress;
  opacity: 0.68;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 12px clamp(16px, 5vw, 48px);
  border-bottom: 1px solid rgba(216, 224, 221, 0.86);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

.brand,
.login-trigger,
.upload-button,
.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand {
  min-width: max-content;
  font-size: 1.03rem;
  font-weight: 760;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #ffffff;
  border-radius: 50%;
  background: var(--accent);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.main-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 24px);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 680;
}

.main-nav a {
  padding: 8px 2px;
  border-bottom: 2px solid transparent;
}

.main-nav a:hover,
.main-nav a:focus-visible,
.main-nav a.is-active {
  color: var(--accent-strong);
  border-color: var(--accent);
  outline: none;
}

.login-trigger,
.upload-button,
.primary-action,
.secondary-action {
  min-height: 42px;
  max-width: 100%;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: normal;
}

.login-trigger {
  min-width: 112px;
  padding: 0 16px;
  color: #ffffff;
  background: var(--ink);
}

a.login-trigger:hover,
a.login-trigger:focus-visible {
  outline: none;
  background: #0f171b;
}

.button-icon svg {
  width: 18px;
  height: 18px;
}

.button-icon {
  flex: 0 0 auto;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.workspace.show-library {
  grid-template-columns: 1fr;
}

.workspace.show-records {
  grid-template-columns: 1fr;
}

.workspace.show-community {
  grid-template-columns: 1fr;
}

.workspace.show-maker {
  grid-template-columns: 1fr;
}

.workspace.show-library .reader-shell,
.workspace.show-library .journal-panel,
.workspace.show-library .records-panel,
.workspace.show-library .community-panel,
.workspace.show-library .maker-panel,
.workspace.show-records .reader-shell,
.workspace.show-records .journal-panel,
.workspace.show-records .library-panel,
.workspace.show-records .community-panel,
.workspace.show-records .maker-panel,
.workspace.show-community .reader-shell,
.workspace.show-community .journal-panel,
.workspace.show-community .library-panel,
.workspace.show-community .records-panel,
.workspace.show-community .maker-panel,
.workspace.show-maker .reader-shell,
.workspace.show-maker .journal-panel,
.workspace.show-maker .library-panel,
.workspace.show-maker .records-panel,
.workspace.show-maker .community-panel,
.workspace.show-reader .library-panel,
.workspace.show-reader .records-panel,
.workspace.show-reader .community-panel,
.workspace.show-reader .maker-panel {
  display: none;
}

.panel,
.reader-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(20, 40, 45, 0.08);
}

.library-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 22px;
  background:
    linear-gradient(110deg, rgba(33, 122, 115, 0.12), transparent 46%),
    #ffffff;
}

.records-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 22px;
  padding: 22px;
}

.community-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 18px;
  padding: 22px;
}

.maker-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 18px;
  padding: 22px;
}

.records-hero,
.community-hero,
.maker-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.records-list-area {
  display: grid;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.summary-copy {
  max-width: 700px;
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 650;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.library-list-area {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.text-action {
  min-height: 34px;
  padding: 0 4px;
  color: var(--accent-strong);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  font-weight: 780;
}

.text-action:hover,
.text-action:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.library-empty {
  padding: 14px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 680;
  overflow-wrap: anywhere;
}

.pattern-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
}

.record-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.record-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(20, 40, 45, 0.08);
}

.record-thumbnail {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #edf5f2;
}

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

.record-card-body {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.record-card-body h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.record-card-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.record-meta span {
  padding: 3px 8px;
  color: var(--accent-strong);
  border: 1px solid rgba(33, 122, 115, 0.24);
  border-radius: 999px;
  background: rgba(33, 122, 115, 0.08);
  font-size: 0.76rem;
  font-weight: 820;
}

.maker-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(88px, 108px));
  align-items: end;
  gap: 10px;
}

.maker-controls label,
.maker-title-row label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 780;
}

.maker-controls input,
.maker-title-row input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  font-weight: 720;
}

.maker-controls input:focus,
.maker-title-row input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(33, 122, 115, 0.14);
}

.maker-title-row {
  width: min(420px, 100%);
}

.maker-photo-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.maker-photo-button,
.maker-delete-button,
.maker-pen-button,
.maker-brush-button,
.maker-erase-button {
  width: auto;
}

.maker-pen-button.is-active {
  background: var(--ink);
  border-color: var(--ink);
}

.maker-brush-button.is-active {
  background: var(--accent);
  border-color: var(--accent);
}

.maker-erase-button.is-active {
  background: var(--coral);
  border-color: var(--coral);
}

.maker-color-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  font-size: 0.88rem;
  font-weight: 780;
}

.maker-color-control input {
  width: 34px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

#makerPhoto {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
}

.maker-threshold {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 780;
}

.maker-threshold input {
  width: 150px;
  accent-color: var(--accent);
}

.maker-photo-preview {
  display: grid;
  gap: 8px;
  width: min(180px, 100%);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
}

.maker-photo-preview[hidden] {
  display: none;
}

.maker-photo-preview img {
  display: block;
  width: 100%;
  height: 92px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.maker-photo-name {
  display: block;
}

.maker-photo-preview span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.maker-canvas-wrap {
  display: grid;
  place-items: center;
  min-height: min(68vh, 720px);
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eef3f1;
}

.maker-grid {
  --maker-columns: 20;
  --maker-rows: 20;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--maker-columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--maker-rows), minmax(0, 1fr));
  width: min(100%, 720px);
  aspect-ratio: var(--maker-columns) / var(--maker-rows);
  min-width: min(100%, 320px);
  max-height: 70vh;
  touch-action: none;
  user-select: none;
  border: 0.5px solid gray;
  background: #ffffff;
}

.maker-placement-selection {
  position: absolute;
  z-index: 3;
  border: 2px solid #ffffff;
  box-shadow:
    0 0 0 1px rgba(17, 17, 17, 0.9),
    inset 0 0 0 1px var(--maker-current-color, rgba(17, 17, 17, 0.28));
  pointer-events: none;
}

.maker-cell {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0.5px solid gray;
  border-radius: 0;
  background: #ffffff;
  cursor: crosshair;
}

.maker-grid.is-erasing .maker-cell {
  cursor: cell;
}

.maker-grid.is-drawing .maker-cell {
  cursor: pointer;
}

.maker-grid.is-brushing .maker-cell {
  cursor: copy;
}

.maker-cell.is-filled {
  background: #111111;
}

.maker-cell:focus-visible {
  position: relative;
  z-index: 2;
  outline: 2px solid var(--coral);
  outline-offset: -2px;
}

.maker-save-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 14px;
}

.maker-save-row .primary-action,
.maker-save-row .secondary-action {
  width: auto;
  min-width: 132px;
}

.maker-save-row .save-status {
  margin-right: auto;
}

.comment-composer {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.comment-composer textarea {
  width: 100%;
  min-height: 94px;
  resize: vertical;
  padding: 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  line-height: 1.5;
}

.comment-composer textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(33, 122, 115, 0.14);
}

.comment-photo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.comment-photo-button {
  min-width: 126px;
}

#commentPhoto {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
}

.comment-photo-preview {
  display: grid;
  grid-template-columns: minmax(0, 180px) auto;
  align-items: center;
  gap: 12px;
}

.comment-photo-preview[hidden] {
  display: none;
}

.comment-photo-preview img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.community-empty {
  padding: 14px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 680;
  overflow-wrap: anywhere;
}

.comment-thread {
  display: grid;
  gap: 14px;
}

.comment-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.comment-item.is-mine {
  grid-template-columns: minmax(0, 1fr) 38px;
}

.comment-item.is-mine .comment-avatar {
  grid-column: 2;
  grid-row: 1;
}

.comment-item.is-mine .comment-bubble {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  background: #eaf5f2;
}

.comment-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #ffffff;
  border-radius: 50%;
  background: var(--accent);
  font-size: 0.78rem;
  font-weight: 860;
}

.comment-bubble {
  display: grid;
  gap: 8px;
  max-width: min(760px, 100%);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
  min-width: 0;
}

.comment-meta-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.comment-meta strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.comment-delete {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 8px;
  color: var(--coral);
  border: 1px solid rgba(215, 106, 95, 0.34);
  border-radius: 6px;
  background: rgba(215, 106, 95, 0.08);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 820;
}

.comment-delete:hover,
.comment-delete:focus-visible {
  color: #ffffff;
  background: var(--coral);
  outline: none;
}

.comment-bubble p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.comment-photo {
  width: min(360px, 100%);
  max-height: 360px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.pattern-item {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 0;
  color: var(--ink);
  text-align: left;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.pattern-item:hover,
.pattern-item:focus-visible,
.pattern-item.is-active {
  outline: none;
}

.pattern-item:hover .pattern-thumbnail,
.pattern-item:focus-visible .pattern-thumbnail,
.pattern-item.is-active .pattern-thumbnail {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(33, 122, 115, 0.12);
}

.pattern-thumbnail {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8faf9;
  box-shadow: 0 8px 24px rgba(20, 40, 45, 0.08);
}

.pattern-thumbnail iframe,
.thumbnail-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pattern-thumbnail iframe {
  z-index: 2;
  border: 0;
  background: #ffffff;
  pointer-events: none;
}

.maker-thumbnail {
  position: absolute;
  inset: 10px;
  z-index: 2;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  background: #ffffff;
}

.maker-thumbnail rect,
.maker-thumbnail path {
  vector-effect: non-scaling-stroke;
}

.thumbnail-placeholder {
  z-index: 1;
  display: grid;
  place-items: center;
  color: var(--accent);
  background:
    linear-gradient(90deg, rgba(25, 36, 42, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(25, 36, 42, 0.04) 1px, transparent 1px),
    #f8faf9;
  background-size: 18px 18px;
}

.thumbnail-placeholder svg {
  width: 46px;
  height: 46px;
}

.pattern-card-footer {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.pattern-file-name {
  min-width: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.knitting-badge {
  flex: 0 0 auto;
  padding: 2px 7px;
  color: var(--accent-strong);
  border: 1px solid rgba(33, 122, 115, 0.28);
  border-radius: 999px;
  background: rgba(33, 122, 115, 0.1);
  font-size: 0.72rem;
  font-weight: 840;
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--coral);
  font-size: 0.76rem;
  font-weight: 840;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h1 {
  max-width: 760px;
  font-size: clamp(1.55rem, 2.8vw, 2.4rem);
  line-height: 1.18;
}

h2 {
  font-size: 1.22rem;
}

.project-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(88px, 1fr));
  gap: 10px;
}

.project-metrics div {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-value,
.metric-label {
  display: block;
}

.metric-value {
  color: var(--accent-strong);
  font-size: 1.4rem;
  font-weight: 860;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 680;
}

.reader-shell {
  min-width: 0;
  padding: 18px;
}

.reader-toolbar,
.reader-options,
.upload-row,
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.reader-toolbar {
  margin-bottom: 14px;
}

.reader-toolbar > div:first-child {
  min-width: min(100%, 340px);
}

.title-input {
  width: min(100%, 360px);
  min-height: 40px;
  margin-top: 10px;
  padding: 0 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  font-weight: 720;
}

.title-input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(33, 122, 115, 0.14);
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.icon-button:hover,
.icon-button:focus-visible,
.icon-button.is-active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
  outline: none;
}

.reader-options {
  flex-wrap: wrap;
  min-height: 54px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.swatches {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

.swatches legend,
.opacity-control span {
  margin-right: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
}

.swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}

.swatch.is-selected {
  box-shadow:
    0 0 0 2px var(--accent),
    0 0 0 5px rgba(33, 122, 115, 0.16);
}

.opacity-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.opacity-control input {
  width: 128px;
  accent-color: var(--accent);
}

.pdf-frame {
  position: relative;
  display: grid;
  place-items: stretch;
  width: 100%;
  height: min(70vh, 720px);
  min-height: 480px;
  overflow: hidden;
  border: 1px solid #cdd8d5;
  border-radius: var(--radius);
  background: #eef3f1;
}

.pdf-frame.has-pdf {
  background: #3f4a4d;
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 56px;
  height: 56px;
  color: var(--accent);
}

.empty-state p {
  margin: 0;
  font-weight: 720;
}

.pdf-viewer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  opacity: 0;
  background: #f4f4f0;
  pointer-events: none;
  -webkit-overflow-scrolling: touch;
}

.pdf-frame.has-pdf .pdf-viewer {
  opacity: 1;
  pointer-events: auto;
}

.pdf-frame.has-pdf .empty-state {
  display: none;
}

.highlight-layer {
  position: relative;
  z-index: 4;
  display: grid;
  justify-items: center;
  gap: 18px;
  min-height: 100%;
  padding: 24px;
  cursor: default;
  pointer-events: auto;
}

.highlight-layer.is-disabled {
  cursor: default;
}

.highlight-layer:not(.is-disabled) {
  cursor: crosshair;
}

.highlight-layer.is-erasing {
  cursor: cell;
}

.pdf-loading {
  align-self: center;
  justify-self: center;
  padding: 14px 18px;
  color: #594236;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  font-weight: 780;
}

.pdf-page {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  max-width: 100%;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(40, 28, 20, 0.18);
}

.pdf-page-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pdf-page-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: auto;
}

.highlight-layer.is-disabled .pdf-page-overlay {
  pointer-events: none;
}

.highlight-layer:not(.is-disabled) .pdf-page-overlay {
  touch-action: none;
}

.highlight {
  cursor: inherit;
  mix-blend-mode: multiply;
  pointer-events: stroke;
}

.highlight.is-drafting {
  outline: none;
}

.eraser-stroke {
  stroke: rgba(255, 255, 255, 0.84);
  filter: drop-shadow(0 0 2px rgba(111, 48, 41, 0.52));
}

.upload-row {
  flex-wrap: wrap;
  padding-top: 14px;
}

.upload-button,
.primary-action,
.secondary-action {
  padding: 0 18px;
  color: #ffffff;
  background: var(--accent);
}

.upload-button:hover,
.upload-button:focus-within,
.primary-action:hover,
.primary-action:focus-visible,
.secondary-action:hover,
.secondary-action:focus-visible {
  background: var(--accent-strong);
}

.secondary-action {
  border: 1px solid var(--accent);
}

#pdfInput {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
}

.file-name {
  min-width: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 680;
  overflow-wrap: anywhere;
}

.save-status {
  min-height: 1.3em;
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 760;
}

.save-status.is-error {
  color: var(--coral);
}

.journal-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  padding: 18px;
}

.journal-panel textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  line-height: 1.6;
}

.journal-panel textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(33, 122, 115, 0.14);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(25, 36, 42, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.login-modal,
.record-modal {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.record-modal {
  width: min(620px, 100%);
  max-height: min(90vh, 820px);
  overflow-y: auto;
}

.record-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.record-photo-preview {
  display: grid;
  place-items: center;
  min-height: 220px;
  overflow: hidden;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
  font-weight: 760;
}

.record-photo-preview img {
  width: 100%;
  height: 100%;
  max-height: 360px;
  object-fit: cover;
  display: block;
}

.auth-page {
  min-height: 100vh;
}

.auth-shell {
  display: grid;
  place-items: center;
  width: min(100% - 32px, 560px);
  min-height: calc(100vh - 110px);
  margin: 0 auto;
  padding: 40px 0;
}

.signup-panel {
  display: grid;
  gap: 22px;
  width: 100%;
  padding: clamp(20px, 4vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.phone-signup-form {
  display: grid;
  gap: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.auth-tab {
  min-height: 36px;
  color: var(--muted);
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-weight: 780;
}

.auth-tab.is-active {
  color: #ffffff;
  background: var(--accent);
}

.form-message {
  min-height: 1.3em;
  margin: -4px 0 0;
  color: var(--coral);
  font-size: 0.88rem;
  font-weight: 720;
}

.dev-code {
  color: var(--accent-strong);
}

.google-login-panel {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 8px 0 4px;
}

.google-login-button {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 44px;
}

.google-login-button > div {
  max-width: 100%;
}

.auth-code-button {
  width: 100%;
}

.auth-link {
  justify-self: center;
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 780;
  border-bottom: 2px solid transparent;
}

.auth-link:hover,
.auth-link:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.login-modal label,
.record-modal label,
.phone-signup-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
}

.login-modal input,
.record-modal input,
.phone-signup-form input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.login-modal input:focus,
.record-modal input:focus,
.phone-signup-form input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(33, 122, 115, 0.14);
}

.primary-action {
  width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .main-nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .library-panel {
    grid-template-columns: 1fr;
  }

  .project-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .records-hero,
  .community-hero,
  .maker-head {
    flex-direction: column;
  }

  .maker-controls {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 560px) {
  .site-header {
    gap: 12px;
    padding: 10px 14px;
  }

  .main-nav {
    flex-wrap: wrap;
    gap: 6px 14px;
    overflow-x: visible;
  }

  .main-nav a {
    padding-block: 6px;
    white-space: nowrap;
  }

  .brand span:last-child {
    display: none;
  }

  .login-trigger {
    min-width: 44px;
    padding: 0 12px;
  }

  .login-trigger #loginLabel {
    display: none;
  }

  .workspace {
    width: min(100% - 20px, 1180px);
    margin-top: 14px;
  }

  .library-panel,
  .records-panel,
  .community-panel,
  .reader-shell,
  .journal-panel,
  .maker-panel {
    padding: 14px;
  }

  h1 {
    font-size: 1.42rem;
    line-height: 1.25;
  }

  h2 {
    font-size: 1.08rem;
    line-height: 1.3;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .reader-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .reader-options {
    align-items: flex-start;
  }

  .tool-group {
    flex-wrap: wrap;
  }

  .opacity-control {
    width: 100%;
    justify-content: space-between;
  }

  .opacity-control input {
    width: min(180px, 58vw);
  }

  .pdf-frame {
    height: 62vh;
    min-height: 360px;
  }

  .maker-canvas-wrap {
    min-height: 360px;
    padding: 10px;
  }

  .maker-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .maker-controls .secondary-action {
    grid-column: 1 / -1;
    width: 100%;
  }

  .maker-photo-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .maker-photo-row .secondary-action {
    width: 100%;
    min-width: 0;
    padding-inline: 12px;
  }

  .maker-photo-preview {
    grid-column: 1 / -1;
    width: 100%;
  }

  .maker-save-row {
    align-items: stretch;
  }

  .maker-save-row .save-status {
    width: 100%;
    margin-right: 0;
  }

  .maker-save-row .primary-action,
  .maker-save-row .secondary-action {
    width: 100%;
    min-width: 0;
  }

  .upload-row .upload-button,
  .upload-row .secondary-action,
  .comment-photo-row .secondary-action,
  .comment-photo-row .primary-action,
  .records-hero .primary-action {
    width: 100%;
    min-width: 0;
  }

  .upload-row .file-name,
  .upload-row .save-status {
    flex-basis: 100%;
  }

  .comment-photo-preview {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .comment-item,
  .comment-item.is-mine {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .comment-item.is-mine .comment-avatar {
    grid-column: 1;
  }

  .comment-item.is-mine .comment-bubble {
    grid-column: 2;
    justify-self: stretch;
  }

  .comment-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.72rem;
  }
}

/* KnitCanvas reference UI */
:root {
  --kc-cream: #fbf6ee;
  --kc-paper: #fffdf8;
  --kc-peach: #f7d8bd;
  --kc-peach-strong: #efbd98;
  --kc-sidebar: #fde2c6;
  --kc-brown: #3f2015;
  --kc-muted: #8a6759;
  --kc-line: #d7b99f;
  --kc-shadow: 0 10px 28px rgba(67, 35, 23, 0.16);
  --bg: var(--kc-cream);
  --surface: var(--kc-paper);
  --surface-2: #fff6e8;
  --ink: var(--kc-brown);
  --muted: var(--kc-muted);
  --line: rgba(119, 77, 55, 0.22);
  --accent: #bd665f;
  --accent-strong: #8c443e;
  --coral: #b85f58;
}

body {
  color: var(--kc-brown);
  background:
    radial-gradient(circle at 84% 18%, rgba(255, 220, 184, 0.45), transparent 28%),
    linear-gradient(90deg, #fffaf2 0%, #f8f2e8 100%);
}

.top-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 24px;
  color: #3f1f14;
  border-bottom: 1px solid rgba(132, 83, 53, 0.14);
  background: linear-gradient(90deg, #f6d1b5, #fce4cc 48%, #f8d4bd);
  font-size: 1rem;
}

.top-strip strong {
  font-weight: 820;
}

.profile-chip {
  justify-self: end;
  min-height: 30px;
  min-width: 0;
  padding: 0;
  color: var(--kc-brown);
  border: 0;
  background: transparent;
  font-size: 0.92rem;
  font-weight: 520;
}

.profile-chip:hover,
.profile-chip:focus-visible {
  color: var(--kc-brown);
  background: transparent;
  outline: none;
}

.profile-chip #loginLabel {
  display: none;
}

.profile-avatar {
  overflow: hidden;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 36%, #ffd4b4 0 20%, transparent 21%),
    radial-gradient(circle at 50% 78%, #8c4636 0 34%, transparent 35%),
    #b56c4e;
  font-size: 0;
  box-shadow: 0 1px 4px rgba(60, 32, 20, 0.2);
}

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

.profile-copy {
  max-width: min(42vw, 260px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-header {
  position: relative;
  top: auto;
  display: grid;
  grid-template-columns: auto minmax(250px, 1fr) minmax(420px, auto);
  min-height: 78px;
  padding: 10px 24px;
  color: var(--kc-brown);
  border-bottom: 1px solid rgba(72, 39, 23, 0.16);
  background: rgba(255, 250, 242, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  gap: 12px;
  color: var(--kc-brown);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 760;
}

.brand-mark {
  width: 52px;
  height: 52px;
  color: #6a2d1f;
  border-radius: 0;
  background: transparent;
}

.brand-mark svg {
  width: 52px;
  height: 52px;
  stroke-width: 1.6;
}

.main-nav {
  justify-content: flex-start;
  gap: clamp(24px, 4vw, 42px);
  color: var(--kc-brown);
  font-size: 1.06rem;
  font-weight: 740;
}

.main-nav a {
  padding: 10px 0;
  border: 0;
}

.main-nav a:hover,
.main-nav a:focus-visible,
.main-nav a.is-active {
  color: #7d3a2e;
  border: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  min-width: 0;
}

.search-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: min(260px, 30vw);
  min-height: 38px;
  padding: 0 12px;
  color: #725548;
  border: 1px solid rgba(95, 57, 39, 0.24);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.64);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.search-field input {
  width: 100%;
  min-height: 34px;
  color: var(--kc-brown);
  border: 0;
  background: transparent;
  font-size: 1rem;
  outline: none;
}

.outline-action,
.save-export-action {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 720;
  white-space: nowrap;
}

.outline-action {
  color: #9a5b4d;
  border: 1px solid #a5685c;
  background: rgba(255, 248, 238, 0.7);
}

.save-export-action,
.header-actions .primary-action {
  width: auto;
  min-width: 112px;
  color: #ffffff;
  border: 1px solid #b76a62;
  background: #bd6c65;
}

.workspace {
  width: 100%;
  max-width: none;
  min-height: calc(100vh - 114px);
  margin: 0;
  gap: 0;
}

.workspace.show-reader {
  grid-template-columns: 1fr;
}

.workspace.show-reader .journal-panel {
  display: none;
}

.reader-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: calc(100vh - 114px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #fbfaf7;
  box-shadow: none;
}

.reader-workspace {
  position: relative;
  display: grid;
  place-items: stretch;
  min-width: 0;
  min-height: calc(100vh - 114px);
  overflow: hidden;
  background:
    radial-gradient(circle at 88% 78%, rgba(255, 255, 255, 0.9) 0 2%, transparent 3%),
    linear-gradient(180deg, #fcfdfb 0%, #f6f8f6 100%);
}

.reader-toolbar {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 8;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(880px, calc(100% - 48px));
  min-height: 80px;
  margin: 0;
  padding: 8px 14px;
  border: 1px solid rgba(111, 82, 62, 0.14);
  border-radius: 12px;
  background: rgba(248, 241, 223, 0.92);
  box-shadow: var(--kc-shadow);
  transform: translateX(-50%);
}

.tool-button {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 54px;
  min-height: 64px;
  padding: 6px 7px;
  color: #2f1a12;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 560;
  line-height: 1.1;
}

.tool-button svg {
  width: 28px;
  height: 28px;
  stroke-width: 1.9;
}

.tool-button:hover,
.tool-button:focus-visible,
.tool-button.is-active {
  color: #2f1a12;
  background: rgba(237, 202, 139, 0.48);
  outline: none;
}

.tool-button.is-muted {
  color: rgba(47, 26, 18, 0.32);
}

.zoom-value {
  min-width: 48px;
  padding: 6px 8px;
  color: #ffffff;
  border-radius: 999px;
  background: #8c443e;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 820;
}

.highlight-button {
  background: rgba(238, 204, 141, 0.62);
}

.delete-all-button {
  color: #6f3029;
}

.reader-toolbar .swatches {
  display: grid;
  grid-template-columns: repeat(2, 22px);
  gap: 7px;
  padding: 0 8px;
}

.reader-toolbar .swatch {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(120, 82, 59, 0.18);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(77, 47, 30, 0.14);
}

.reader-toolbar .swatch.is-selected {
  box-shadow:
    0 0 0 2px #f8eed9,
    0 0 0 4px rgba(167, 91, 80, 0.38);
}

.thickness-control {
  display: grid;
  grid-template-columns: auto minmax(58px, 92px) 24px;
  align-items: center;
  gap: 7px;
  min-width: 142px;
  padding: 7px 9px;
  color: #3b2117;
  border-radius: 8px;
  background: rgba(255, 250, 239, 0.64);
  font-size: 0.78rem;
  font-weight: 740;
}

.thickness-control input {
  width: 100%;
  accent-color: #bd6c65;
}

.thickness-control output {
  min-width: 24px;
  padding: 2px 5px;
  color: #ffffff;
  border-radius: 999px;
  background: #8c443e;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 820;
}

.pdf-frame {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 114px);
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.pdf-frame.has-pdf {
  background: #f4f4f0;
}

.empty-state {
  inset: 0;
  color: #594236;
  cursor: pointer;
}

.empty-state svg {
  width: 116px;
  height: 116px;
  color: #5a4336;
  stroke-width: 1.2;
}

.empty-state span,
.empty-state p {
  display: block;
  margin: 18px 0 0;
  color: #4e3a31;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  font-weight: 820;
  letter-spacing: -0.02em;
}

.upload-row {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 16px;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 0;
  pointer-events: none;
}

.upload-row .upload-button,
.upload-row .file-name,
.upload-row .save-status {
  pointer-events: auto;
}

.upload-row .upload-button {
  min-height: 36px;
  padding: 0 12px;
  color: #815045;
  border: 1px solid rgba(129, 80, 69, 0.28);
  background: rgba(255, 250, 242, 0.82);
}

.upload-row .file-name,
.upload-row .save-status {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.8);
}

.title-input.sr-only {
  position: absolute;
}

@media (max-width: 1120px) {
  .site-header {
    grid-template-columns: auto 1fr;
  }

  .header-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .search-field {
    width: min(360px, 100%);
  }

  .reader-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .reader-toolbar {
    width: min(680px, calc(100% - 32px));
    overflow-x: auto;
    justify-content: flex-start;
  }
}

@media (max-width: 820px) {
  .top-strip {
    grid-template-columns: auto 1fr;
    padding: 6px 14px;
  }

  .profile-chip {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .site-header {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 12px;
    padding: 12px 14px;
  }

  .brand {
    font-size: 1.65rem;
  }

  .brand-mark,
  .brand-mark svg {
    width: 42px;
    height: 42px;
  }

  .main-nav {
    gap: 20px;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 10px;
  }

  .search-field {
    width: 100%;
  }

  .outline-action,
  .save-export-action {
    flex: 1 1 140px;
  }

  .workspace,
  .reader-shell,
  .reader-workspace,
  .pdf-frame {
    min-height: auto;
  }

  .reader-shell {
    grid-template-columns: 1fr;
  }

  .reader-workspace {
    min-height: 62vh;
  }

  .reader-toolbar {
    position: relative;
    top: auto;
    left: auto;
    flex-direction: row;
    flex-wrap: nowrap;
    width: auto;
    margin: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    transform: none;
  }

  .pdf-frame {
    height: 62vh;
    min-height: 430px;
  }
}

@media (max-width: 560px) {
  .top-strip {
    font-size: 0.9rem;
  }

  .brand {
    font-size: 1.45rem;
  }

  .brand span:last-child {
    display: inline;
  }

  .main-nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .tool-button {
    flex: 0 0 auto;
    min-width: 50px;
    font-size: 0.76rem;
  }

  .empty-state svg {
    width: 84px;
    height: 84px;
  }

  .empty-state span,
  .empty-state p {
    max-width: min(280px, 86vw);
    font-size: 1.55rem;
    line-height: 1.25;
  }

  .upload-row {
    position: static;
    padding: 12px;
    background: #fbfaf7;
    pointer-events: auto;
  }
}
