@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&display=swap');

:root {
  color-scheme: light;
  --paper: #f6f5ef;
  --panel: #fffefa;
  --ink: #202920;
  --muted: #777c72;
  --line: #e6e7df;
  --green: #315b45;
  --green-dark: #234531;
  --coral: #d3755f;
  --soft-green: #edf2eb;
  --sans: 'DM Sans', 'Noto Sans KR', sans-serif;
  --serif: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(#3446330b 0.65px, transparent 0.65px);
  background-size: 8px 8px;
  font-family: var(--sans);
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(1120px, calc(100% - 64px));
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #dfe1d8;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}

.wordmark-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-family: var(--serif);
  font-size: 16px;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d0a34d;
}
.connection-dot.is-online { background: #57956a; }
.connection-dot.is-offline { background: var(--coral); }

.workspace {
  flex: 1;
  min-height: 560px;
  margin: 42px 0 28px;
  animation: arrive 500ms ease-out both;
}

.notes-panel {
  padding: 0;
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 0 4px 22px;
}

.eyebrow {
  margin: 0;
  color: #8d9387;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

.panel-heading h1 {
  margin: 7px 0 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
}

.note-count {
  min-width: 25px;
  padding: 4px 7px;
  border-radius: 12px;
  color: var(--green);
  background: var(--soft-green);
  font-size: 11px;
  text-align: center;
}

.new-note-button {
  min-height: 40px;
  margin: 0 0 25px 4px;
  padding: 0 15px;
  border: 1px solid var(--green);
  border-radius: 2px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease;
}
.new-note-button span { margin-right: 7px; font-size: 18px; vertical-align: -1px; }
.new-note-button:hover { border-color: var(--green-dark); background: var(--green-dark); }

.notes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  align-content: start;
  gap: 24px;
  padding: 4px 5px 30px;
}

.note-item {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 190px;
  padding: 28px 22px 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border: 0;
  border-radius: 1px 1px 3px 1px;
  background: #f5e99b;
  box-shadow: 2px 5px 10px #343b281c, 0 1px 2px #343b2810;
  cursor: pointer;
  text-align: left;
  transform: rotate(-1deg);
  transition: box-shadow 180ms ease, transform 180ms ease;
}
.note-item::before {
  width: 62px;
  height: 18px;
  position: absolute;
  top: -7px;
  left: calc(50% - 31px);
  background: #ffffff75;
  content: "";
  transform: rotate(-2deg);
}
.note-item:nth-child(4n + 2) { transform: rotate(1.2deg); }
.note-item:nth-child(4n + 3) { transform: rotate(-0.4deg); }
.note-item:nth-child(4n) { transform: rotate(1.5deg); }
.note-item[data-color="mint"] { background: #cfe5c8; }
.note-item[data-color="peach"] { background: #f4d1b8; }
.note-item[data-color="sky"] { background: #c9e2e9; }
.note-item:hover, .note-item.is-selected {
  z-index: 1;
  box-shadow: 4px 12px 20px #343b2828, 0 2px 4px #343b2810;
  transform: rotate(0) translateY(-4px);
}
.note-item-title {
  display: block;
  overflow: hidden;
  color: #303a30;
  font-family: var(--serif), 'Noto Sans KR', serif;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.note-item-preview {
  display: block;
  overflow: hidden;
  flex: 1;
  margin-top: 10px;
  color: #4c5549;
  font-size: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}
.note-item-date {
  display: block;
  margin-top: 12px;
  color: #68705f;
  font-size: 10px;
}
.empty-list {
  grid-column: 1 / -1;
  margin: 0;
  padding: 42px 24px;
  border: 1px dashed #c9cbbd;
  color: #8a8e85;
  background: #ffffff55;
  font-size: 13px;
  line-height: 1.8;
  text-align: center;
}

.editor-dialog {
  width: min(620px, calc(100% - 32px));
  max-width: none;
  max-height: min(760px, calc(100% - 32px));
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 2px;
  background: #f8efb8;
  box-shadow: 4px 18px 55px #20292040;
  transform: rotate(-0.35deg);
}
.editor-dialog[open] { animation: note-pop 180ms ease-out both; }
.editor-dialog::backdrop { background: #26312775; backdrop-filter: blur(2px); }
.editor-dialog .editor-panel {
  min-height: 510px;
  padding: 35px 42px 30px;
  background-image: repeating-linear-gradient(transparent 0 31px, #50644316 32px);
  background-position: 0 123px;
}
.close-editor {
  width: 32px;
  height: 32px;
  margin-left: 8px;
  order: 2;
  border: 1px solid #5c625344;
  border-radius: 50%;
  color: #555c50;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.close-editor:hover { background: #ffffff70; }
.editor-topline .save-status { margin-left: auto; }
.editor-topline .eyebrow { margin-right: auto; }
.editor-dialog .title-input { margin-top: 23px; }
.editor-dialog .content-input { min-height: 230px; }
.editor-dialog .editor-footer { border-color: #66745138; }
.editor-dialog .editor-rule { background: #66745138; }
.editor-dialog .feedback {
  border-left-color: var(--coral);
  background: #fbefeb;
}

@keyframes note-pop {
  from { opacity: 0; transform: translateY(8px) rotate(-0.35deg) scale(0.98); }
  to { opacity: 1; transform: translateY(0) rotate(-0.35deg) scale(1); }
}

.editor-panel {
  min-width: 0;
  padding: 34px 42px 30px;
  display: flex;
  flex-direction: column;
}
.editor-topline {
  min-height: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.save-status { color: #9a9e95; font-size: 11px; }
#note-form { flex: 1; display: flex; flex-direction: column; }
.title-input {
  width: 100%;
  margin-top: 23px;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: var(--serif), 'Noto Sans KR', serif;
  font-size: 29px;
  font-weight: 500;
}
.title-input::placeholder { color: #aeb2a9; }
.editor-rule { height: 1px; margin: 18px 0 13px; background: var(--line); }
.content-input {
  width: 100%;
  flex: 1;
  min-height: 250px;
  resize: vertical;
  padding: 6px 0;
  border: 0;
  outline: 0;
  color: #444c42;
  background: transparent;
  font-size: 14px;
  line-height: 1.9;
}
.content-input::placeholder { color: #adb0a7; }
.editor-footer {
  min-height: 48px;
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
}
.privacy-note { color: #999d93; font-size: 11px; }
.delete-button {
  width: 36px;
  height: 36px;
  margin-left: auto;
  border: 1px solid #eadbd6;
  border-radius: 3px;
  color: #a75040;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.delete-button:hover { background: #fbefeb; }
.delete-button:disabled { cursor: wait; opacity: 0.55; }
.delete-button[hidden] { display: none; }
.save-button {
  min-height: 36px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 3px;
  color: white;
  background: var(--green);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 150ms ease, transform 150ms ease;
}
.save-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.save-button:disabled { cursor: wait; opacity: 0.65; transform: none; }
.feedback {
  margin: 14px 0 0;
  padding: 11px 12px;
  border-left: 3px solid var(--coral);
  color: #8f4536;
  background: #fbefeb;
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.feedback[hidden] { display: none; }
.page-footer {
  padding: 0 0 23px;
  color: #91958b;
  font-size: 11px;
  text-align: center;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 700px) {
  .app-shell { width: min(100% - 28px, 560px); }
  .topbar { height: 66px; }
  .workspace { min-height: 0; margin-top: 28px; }
  .panel-heading { margin-bottom: 20px; }
  .notes-list {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 18px;
    padding-inline: 3px;
  }
  .note-item { min-height: 165px; padding: 24px 16px 16px; }
  .note-item-title { font-size: 17px; }
  .note-item-preview { font-size: 11px; }
  .editor-dialog .editor-panel { min-height: 460px; padding: 26px 20px 20px; }
  .editor-dialog .title-input { font-size: 25px; }
  .editor-dialog .content-input { min-height: 210px; }
  .editor-dialog .privacy-note { max-width: 170px; line-height: 1.5; }
  .page-footer { padding: 0 0 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
