:root {
  color-scheme: light;
  --post-write-primary: var(--fdc-shell-primary, var(--fdc-color-accent, #3B82F6));
  --post-write-primary-strong: var(--fdc-color-accent-strong, #2563EB);
  --post-write-primary-soft: var(--fdc-color-accent-soft, #DBEAFE);
  --post-write-bg: #F8FAFC;
  --post-write-surface: #FFFFFF;
  --post-write-surface-soft: #F8FAFC;
  --post-write-border: var(--fdc-border-panel, var(--fdc-color-border, #d6e3f2));
  --post-write-border-strong: var(--fdc-border-panel-strong, var(--fdc-color-border-strong, #c3d4e8));
  --post-write-text: #0F172A;
  --post-write-sub: #64748B;
  --post-write-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --post-write-primary: var(--fdc-color-accent-strong, #2563EB);
  --post-write-primary-strong: #BFDBFE;
  --post-write-primary-soft: rgba(37, 99, 235, 0.22);
  --post-write-bg: #0B1220;
  --post-write-surface: #111827;
  --post-write-surface-soft: rgba(15, 23, 42, 0.92);
  --post-write-border: var(--fdc-border-panel, var(--fdc-color-border, #3b4d68));
  --post-write-border-strong: var(--fdc-border-panel-strong, var(--fdc-color-border-strong, #4b6282));
  --post-write-text: #E2E8F0;
  --post-write-sub: #94A3B8;
  --post-write-shadow: 0 22px 48px rgba(2, 6, 23, 0.32);
}

:root[data-theme='dark'] .post-write-field input::placeholder,
:root[data-theme='dark'] .milkdown .crepe-placeholder::before {
  color: #64748B;
}

:root[data-theme='dark'] .post-write-switch-track {
  background: #334155;
}

:root[data-theme='dark'] .post-editor,
:root[data-theme='dark'] .post-editor-head,
:root[data-theme='dark'] .post-write-editor-host,
:root[data-theme='dark'] .post-write-editor-host .milkdown,
:root[data-theme='dark'] .post-write-editor-host .milkdown .milkdown-top-bar,
:root[data-theme='dark'] .post-editor-preview {
  background: var(--post-write-surface);
  color: var(--post-write-text);
}

:root[data-theme='dark'] .post-editor-head {
  background: var(--post-write-surface-soft);
}

:root[data-theme='dark'] .post-editor-tab.is-active {
  background: rgba(37, 99, 235, 0.24);
  color: #bfdbfe;
}

:root[data-theme='dark'] .post-write-button.is-primary {
  background: var(--post-write-primary);
}

:root[data-theme='dark'] .post-editor-tab,
:root[data-theme='dark'] .post-editor-caption,
:root[data-theme='dark'] .post-write-editor-host .milkdown .top-bar-heading-button,
:root[data-theme='dark'] .post-write-editor-host .milkdown .top-bar-item,
:root[data-theme='dark'] .post-write-editor-host .milkdown .top-bar-heading-label {
  color: #94a3b8;
}

* {
  box-sizing: border-box;
}

body.post-write-page {
  margin: 0;
  min-height: 100vh;
  background: var(--post-write-bg);
  color: var(--post-write-text);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20;
  line-height: 1;
}

.post-write-main {
  width: min(1120px, calc(100% - 28px));
  margin: 24px auto 48px;
  flex: 1 0 auto;
}

.post-write-state {
  min-height: 320px;
  display: grid;
  place-items: center;
}

.post-write-state[hidden] {
  display: none;
}

.post-write-state .fdc-loading-stack {
  width: min(420px, 100%);
}

.post-write-surface[hidden] {
  display: none;
}

.post-write-head {
  margin-bottom: 18px;
  padding: 0 2px;
}

.post-write-head h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.post-write-card {
  background: var(--post-write-surface);
  border: 1px solid var(--post-write-border);
  border-radius: 16px;
  box-shadow: var(--post-write-shadow);
  padding: 22px;
  display: grid;
  gap: 18px;
}

.post-write-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 248px));
  justify-content: flex-start;
  gap: 12px;
}

.post-write-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.post-write-field label {
  color: var(--post-write-sub);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.post-write-field input {
  width: 100%;
  border: 1px solid var(--post-write-border-strong);
  border-radius: 10px;
  background: var(--post-write-surface);
  color: var(--post-write-text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.post-write-field input {
  min-height: 46px;
  padding: 0 14px;
}

.post-write-field input:focus {
  outline: none;
  border-color: var(--post-write-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.post-write-field input::placeholder {
  color: #94A3B8;
}

.post-write-select-wrap {
  position: relative;
}

.post-write-select {
  display: none;
}

.post-write-select-dropdown {
  width: 100%;
}

.post-write-filter-trigger {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--post-write-border-strong);
  border-radius: 10px;
  background: var(--post-write-surface);
  color: var(--post-write-text);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease,
    color 140ms ease;
}

.post-write-filter-trigger .filter-trigger-label {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-write-filter-trigger .filter-trigger-caret {
  color: var(--fdc-dropdown-caret-color);
  font-size: 18px;
  line-height: 1;
  transition: color 140ms ease, transform 140ms ease;
}

.post-write-filter-trigger:hover {
  border-color: var(--post-write-primary);
  background: var(--post-write-surface-soft);
}

.post-write-select-dropdown.is-open .post-write-filter-trigger {
  border-color: var(--post-write-border-strong);
  background: var(--post-write-surface);
  color: var(--post-write-text);
}

.post-write-filter-trigger:focus-visible {
  outline: none;
  border-color: var(--post-write-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.post-write-select-dropdown.is-open .post-write-filter-trigger .filter-trigger-caret {
  color: var(--fdc-dropdown-caret-active-color);
  transform: rotate(180deg);
}

.post-write-filter-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 24;
  width: max-content;
  min-width: 0;
  max-width: min(320px, calc(100vw - 24px));
  max-height: min(320px, calc(100dvh - 180px));
  border: 1px solid var(--post-write-border-strong);
  color: var(--post-write-text);
}

.post-write-filter-menu[hidden] {
  display: none !important;
}

.post-write-hint {
  color: var(--post-write-sub);
  font-size: 0.8rem;
  line-height: 1.5;
}

.post-editor {
  border: 1px solid var(--post-write-border-strong);
  border-radius: 14px;
  overflow: hidden;
  background: var(--post-write-surface);
}

.post-editor-head {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--post-write-border);
  background: var(--post-write-surface-soft);
}

.post-editor-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.post-editor-tab,
.post-editor-tool,
.post-write-button {
  font: inherit;
}

.post-editor-tab {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--post-write-sub);
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.post-editor-tab.is-active {
  background: var(--post-write-primary-soft);
  color: var(--post-write-primary-strong);
}

.post-editor-caption {
  color: var(--post-write-sub);
  font-size: 0.8rem;
  font-weight: 700;
}

.post-write-editor-host {
  background: var(--post-write-surface);
}

.post-write-editor-host .milkdown {
  --crepe-color-background: var(--post-write-surface);
  --crepe-color-on-background: var(--post-write-text);
  --crepe-color-surface: var(--post-write-surface-soft);
  --crepe-color-surface-low: color-mix(in srgb, var(--post-write-surface-soft) 78%, var(--post-write-surface));
  --crepe-color-on-surface: var(--post-write-text);
  --crepe-color-on-surface-variant: var(--post-write-sub);
  --crepe-color-outline: var(--post-write-border);
  --crepe-color-primary: var(--post-write-primary-strong);
  --crepe-color-secondary: var(--post-write-primary-soft);
  --crepe-color-on-secondary: var(--post-write-primary-strong);
  --crepe-color-inverse: var(--post-write-text);
  --crepe-color-on-inverse: var(--post-write-surface);
  --crepe-color-inline-code: var(--post-write-primary-strong);
  --crepe-color-error: #DC2626;
  --crepe-color-hover: color-mix(in srgb, var(--post-write-primary-soft) 78%, var(--post-write-surface));
  --crepe-color-selected: color-mix(in srgb, var(--post-write-primary-soft) 70%, transparent);
  --crepe-color-inline-area: color-mix(in srgb, var(--post-write-primary-soft) 68%, var(--post-write-surface));
  --crepe-font-title: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --crepe-font-default: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --crepe-font-code: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  box-shadow: none;
}

.post-write-editor-host .milkdown .milkdown-top-bar {
  padding: 8px 10px;
  border-bottom: 1px solid var(--post-write-border);
  background: var(--post-write-surface);
}

.post-write-editor-host .milkdown .top-bar-divider {
  background: var(--post-write-border);
}

.post-write-editor-host .milkdown .top-bar-heading-button,
.post-write-editor-host .milkdown .top-bar-item {
  min-width: 34px;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--post-write-sub);
}

.post-write-editor-host .milkdown .top-bar-heading-button .top-bar-heading-label {
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
}

.post-write-editor-host .milkdown .top-bar-item.active,
.post-write-editor-host .milkdown .top-bar-heading-option.active {
  background: var(--post-write-primary-soft);
  color: var(--post-write-primary-strong);
}

.post-write-editor-host .milkdown .ProseMirror {
  min-height: 360px;
  padding: 16px;
  color: var(--post-write-text);
  font-size: 0.95rem;
  line-height: 1.75;
}

.post-write-editor-host .milkdown .ProseMirror:focus {
  outline: none;
}

.post-write-editor-host .milkdown .ProseMirror h1,
.post-write-editor-host .milkdown .ProseMirror h2,
.post-write-editor-host .milkdown .ProseMirror h3,
.post-write-editor-host .milkdown .ProseMirror h4 {
  color: var(--post-write-text);
  font-weight: 800;
}

.post-write-editor-host .milkdown .ProseMirror p,
.post-write-editor-host .milkdown .ProseMirror li,
.post-write-editor-host .milkdown .ProseMirror blockquote {
  color: var(--post-write-text);
}

.post-write-editor-host .milkdown .ProseMirror code {
  border-radius: 6px;
}

.post-write-editor-host .milkdown .ProseMirror blockquote {
  color: var(--post-write-sub);
}

.post-write-editor-host .milkdown .ProseMirror a {
  color: var(--post-write-primary-strong);
}

.post-write-editor-host.is-preview-mode .milkdown .milkdown-top-bar {
  background: color-mix(in srgb, var(--post-write-surface-soft) 82%, var(--post-write-surface));
}

.post-write-editor-host.is-preview-mode .milkdown .top-bar-item,
.post-write-editor-host.is-preview-mode .milkdown .top-bar-heading-button {
  color: color-mix(in srgb, var(--post-write-sub) 72%, transparent);
}

.post-write-editor-host.is-preview-mode .milkdown .ProseMirror {
  display: none;
}

.post-editor-preview {
  min-height: 360px;
  padding: 18px 18px 20px;
  background: var(--post-write-surface);
}

.post-editor-preview.is-empty {
  color: var(--post-write-sub);
  font-size: 0.92rem;
  line-height: 1.6;
}

.post-write-options {
  display: flex;
  align-items: center;
  gap: 16px;
}

.post-write-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.post-write-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.post-write-switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #CBD5E1;
  transition: background-color 140ms ease;
}

.post-write-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.14);
  transition: transform 140ms ease;
}

.post-write-switch input:checked + .post-write-switch-track {
  background: var(--post-write-primary);
}

.post-write-switch input:checked + .post-write-switch-track::after {
  transform: translateX(18px);
}

.post-write-switch-label {
  color: var(--post-write-sub);
  font-size: 0.88rem;
  font-weight: 700;
}

.post-write-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--post-write-border);
}

.post-write-status-text {
  margin: 0;
  margin-right: auto;
  color: var(--post-write-sub);
  font-size: 0.83rem;
  line-height: 1.5;
}

.post-write-status-text:empty {
  display: none;
}

.post-write-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.post-write-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.post-write-button.is-subtle {
  background: transparent;
  border-color: var(--post-write-border);
  color: var(--post-write-sub);
}

.post-write-button.is-subtle:hover {
  background: var(--post-write-surface-soft);
  color: var(--post-write-text);
}

.post-write-button.is-primary {
  background: var(--post-write-primary);
  color: #FFFFFF;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.16);
}

.post-write-button.is-primary:hover {
  background: var(--post-write-primary-strong);
  transform: translateY(-1px);
}

.post-write-button:disabled,
.post-editor-tab:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.post-write-markdown {
  color: var(--post-write-text);
  font-size: 0.95rem;
  line-height: 1.75;
}

.post-write-markdown h1,
.post-write-markdown h2,
.post-write-markdown h3,
.post-write-markdown h4 {
  margin: 0 0 12px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.post-write-markdown h1 { font-size: 1.42rem; }
.post-write-markdown h2 { font-size: 1.26rem; }
.post-write-markdown h3 { font-size: 1.12rem; }
.post-write-markdown h4 { font-size: 1rem; }

.post-write-markdown p,
.post-write-markdown ul,
.post-write-markdown ol,
.post-write-markdown blockquote,
.post-write-markdown pre {
  margin: 0 0 14px;
}

.post-write-markdown ul,
.post-write-markdown ol {
  padding-left: 20px;
}

.post-write-markdown blockquote {
  padding: 12px 14px;
  border-left: 3px solid var(--post-write-primary);
  background: var(--post-write-surface-soft);
  color: var(--post-write-sub);
  border-radius: 0 10px 10px 0;
}

.post-write-markdown pre {
  padding: 14px;
  border-radius: 10px;
  background: #0F172A;
  color: #E2E8F0;
  overflow-x: auto;
}

.post-write-markdown code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.92em;
  padding: 0.14em 0.34em;
  border-radius: 6px;
  background: var(--post-write-primary-soft);
  color: var(--post-write-primary-strong);
}

.post-write-markdown pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.post-write-markdown a {
  color: var(--post-write-primary-strong);
  text-decoration: underline;
}

@media (max-width: 860px) {
  .post-write-main {
    width: min(100%, calc(100% - 20px));
    margin-top: 18px;
  }

  .post-write-grid {
    grid-template-columns: 1fr;
  }

  .post-write-filter-menu {
    max-width: 100%;
  }

  .post-write-card {
    padding: 18px;
  }

  .post-write-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .post-write-actions {
    width: 100%;
  }

  .post-write-button {
    flex: 1 1 0;
  }

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