:root {
  color-scheme: light dark;
  --paper: #f4f1ea;
  --surface: #fffdf9;
  --ink: #1d1b18;
  --muted: #777168;
  --line: #ded7cc;
  --accent: #375f4a;
  --accent-ink: #eff8f0;
  --danger: #a3362d;
  --focus: #d8b75a;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Pretendard", "Apple SD Gothic Neo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea, [contenteditable] { font: inherit; }
button { cursor: pointer; }

.writer-shell {
  width: min(100% - 32px, 920px);
  margin: 0 auto;
  padding: 24px 0 88px;
}

.writer-header, .writer-intro, .manager-heading, .editor-actions, .preview-topline {
  display: flex;
  align-items: center;
}

.writer-header {
  justify-content: space-between;
  min-height: 38px;
  margin-bottom: 56px;
}

.brand { color: var(--ink); font-size: 17px; font-weight: 780; letter-spacing: -0.04em; text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.autosave-status { color: var(--muted); font-size: 12px; }

.login-card, .editor-card, .preview-card, .post-manager {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(53, 45, 34, 0.06);
}

.login-card {
  width: min(100%, 440px);
  margin: 12vh auto 0;
  padding: 38px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.login-card h1, .writer-intro h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.055em; line-height: 1.2; }
.login-card > p:not(.eyebrow) { margin: 14px 0 30px; color: var(--muted); line-height: 1.65; }
.login-card form { display: grid; gap: 10px; }
.login-card label { font-size: 13px; font-weight: 700; }

input[type="password"] {
  width: 100%;
  padding: 13px 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: transparent;
}

input[type="password"]:focus, .title-input:focus, .body-input:focus, .drop-zone:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}

.writer-intro { justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.writer-intro .eyebrow { margin-bottom: 8px; }

.editor-card { overflow: hidden; }
.title-input {
  width: 100%;
  padding: 34px 38px 28px;
  color: var(--ink);
  border: 0;
  outline: none;
  background: transparent;
  font-size: clamp(26px, 4vw, 39px);
  font-weight: 760;
  letter-spacing: -0.052em;
}
.title-input::placeholder, .body-input::placeholder { color: color-mix(in srgb, var(--muted) 67%, transparent); }
.editor-divider { height: 1px; margin: 0 38px; background: var(--line); }
.body-input {
  display: block;
  width: 100%;
  min-height: 300px;
  padding: 30px 38px 20px;
  color: var(--ink);
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px;
  line-height: 1.9;
}

.rich-body-input {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rich-body-input:empty::before {
  color: color-mix(in srgb, var(--muted) 67%, transparent);
  content: attr(data-placeholder);
  pointer-events: none;
}

.inline-image-block {
  position: relative;
  display: block;
  width: min(100%, 520px);
  margin: 20px 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #e8e4dc;
  white-space: normal;
}

.inline-image-block img { display: block; width: 100%; max-height: 540px; object-fit: contain; background: #e8e4dc; }
.inline-image-block.is-uploading::after { content: "사진 업로드 중"; position: absolute; inset: auto 10px 10px; padding: 5px 8px; color: #fff; border-radius: 5px; background: rgba(0,0,0,.65); font-size: 11px; }
.inline-image-remove { position: absolute; top: 9px; right: 9px; width: 30px; height: 30px; padding: 0; color: #fff; border: 0; border-radius: 50%; background: rgba(0,0,0,.62); font-size: 19px; line-height: 1; }
.inline-image-remove:hover { background: rgba(0,0,0,.82); }

.attachment-area { padding: 8px 38px 25px; }
.drop-zone {
  display: grid;
  grid-template-columns: 25px 1fr;
  column-gap: 10px;
  align-items: center;
  min-height: 68px;
  padding: 14px 16px;
  color: var(--muted);
  border: 1px dashed color-mix(in srgb, var(--line) 90%, var(--muted));
  border-radius: 11px;
  outline: none;
  transition: 160ms ease;
}
.drop-zone:hover, .drop-zone.is-dragging { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, transparent); }
.drop-zone strong { color: var(--ink); font-size: 14px; }
.drop-zone span:last-child { grid-column: 2; margin-top: 4px; font-size: 12px; }
.drop-icon { grid-row: span 2; display: grid; place-items: center; width: 23px; height: 23px; color: var(--accent); border: 1px solid currentColor; border-radius: 50%; font-size: 20px; font-weight: 300; line-height: 1; }

.form-message { min-height: 20px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.form-message.is-error { color: var(--danger); }
.form-message.is-success { color: var(--accent); }
.editor-card > .form-message { padding: 0 38px 14px; }
.editor-actions { gap: 10px; padding: 18px 38px 28px; border-top: 1px solid var(--line); }
.action-spacer { flex: 1; }

.primary-button, .quiet-button, .danger-button {
  min-height: 39px;
  padding: 0 15px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 750;
  transition: 150ms ease;
}
.primary-button { color: var(--accent-ink); border: 1px solid var(--accent); background: var(--accent); }
.primary-button:hover { filter: brightness(.92); }
.quiet-button { color: var(--ink); border: 1px solid var(--line); background: transparent; }
.quiet-button:hover { border-color: var(--muted); }
.danger-button { color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--line)); background: transparent; }
.danger-button:hover { color: white; border-color: var(--danger); background: var(--danger); }
button:disabled { cursor: wait; opacity: .52; }

.preview-card { margin-top: 28px; overflow: hidden; }
.preview-topline { justify-content: space-between; min-height: 56px; padding: 0 25px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 750; }
.preview-card article { padding: 34px 38px 40px; }
.preview-card time { color: var(--muted); font-size: 13px; }
.preview-card h2 { margin: 13px 0 26px; font-size: clamp(26px, 4vw, 38px); letter-spacing: -0.05em; line-height: 1.28; }
.preview-content { overflow-wrap: anywhere; font-size: 16px; line-height: 1.9; }
.preview-content p { margin: 0 0 22px; white-space: pre-wrap; }
.preview-content img { display: block; width: min(100%, 520px); margin: 22px 0; border: 1px solid var(--line); border-radius: 8px; }

.post-manager { margin-top: 54px; overflow: hidden; }
.manager-heading { justify-content: space-between; min-height: 64px; padding: 0 26px; border-bottom: 1px solid var(--line); }
.manager-heading h2 { margin: 0; font-size: 18px; letter-spacing: -0.035em; }
.manager-heading span { color: var(--muted); font-size: 13px; }
.manager-list:empty::after { content: "아직 내가 쓴 글이 없습니다."; display: block; padding: 26px; color: var(--muted); font-size: 14px; }
.manager-item { display: grid; grid-template-columns: 1fr auto; gap: 15px; align-items: center; width: 100%; padding: 20px 26px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; text-align: left; }
.manager-item:last-child { border-bottom: 0; }
.manager-item:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.manager-item strong { display: block; overflow: hidden; font-size: 15px; letter-spacing: -0.02em; text-overflow: ellipsis; white-space: nowrap; }
.manager-item p { display: -webkit-box; overflow: hidden; margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.manager-item time { color: var(--muted); font-size: 12px; white-space: nowrap; }

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

@media (max-width: 600px) {
  .writer-shell { width: min(100% - 22px, 920px); padding-top: 16px; }
  .writer-header { margin-bottom: 34px; }
  .login-card { margin-top: 6vh; padding: 28px 22px; }
  .title-input { padding: 27px 22px 22px; }
  .editor-divider { margin: 0 22px; }
  .body-input { min-height: 270px; padding: 24px 22px 16px; }
  .attachment-area { padding: 8px 22px 20px; }
  .editor-card > .form-message { padding: 0 22px 12px; }
  .editor-actions { padding: 16px 22px 22px; }
  .preview-card article { padding: 28px 22px 30px; }
  .manager-heading, .manager-item { padding-left: 18px; padding-right: 18px; }
  .inline-image-block { width: 100%; }
}

@media (prefers-color-scheme: dark) {
  :root { --paper: #151512; --surface: #1d1c18; --ink: #f1efe8; --muted: #aaa49a; --line: #39372f; --accent: #77ae89; --accent-ink: #122719; --danger: #ef8076; --focus: #d6b960; }
  .login-card, .editor-card, .preview-card, .post-manager { box-shadow: none; }
  .attachment-card { background: #2b2923; }
}
