:root {
  --bg: #000000;
  --fg: #ffffff;
  --muted: #6b6b6b;
  --line: #1c1c1c;
  --accent: #ffffff;
  --max-width: 46rem;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Apple SD Gothic Neo", "Malgun Gothic",
    "Noto Sans KR", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
}

/* Toolbar */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  transition: opacity 0.4s ease;
}

/* 입력 중에는 툴바를 은은하게 흐리게 해서 글에 집중 */
body.writing .toolbar {
  opacity: 0.12;
}
/* 마우스를 움직이거나 툴바에 올리면 다시 또렷하게 */
body.writing.mouse-active .toolbar,
body.writing .toolbar:hover {
  opacity: 1;
}

.brand {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}
.brand:hover {
  opacity: 0.85;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.status,
.counts {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.btn {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.08s ease;
}
.btn:hover {
  opacity: 0.85;
}
.btn:active {
  transform: translateY(1px);
}

/* Editor layout with ad rails */
.editor-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  width: 100%;
}

.ad-sidebar {
  display: none;
  width: 160px;
  flex-shrink: 0;
  padding: 1rem 0.5rem;
  min-height: 250px;
}

@media (min-width: 1100px) {
  .ad-sidebar {
    display: block;
  }
}

.ad-anchor {
  flex-shrink: 0;
  min-height: 90px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.95);
  padding: 0.35rem 1rem;
  transition: opacity 0.4s ease;
}

body.writing .ad-anchor {
  opacity: 0.15;
}

body.writing.mouse-active .ad-anchor,
body.writing .ad-anchor:hover {
  opacity: 1;
}

body.ad-interstitial-open {
  overflow: hidden;
}

/* Ad slots & interstitial */
.ad-slot--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: inherit;
  background: #0d0d0d;
  border: 1px dashed #2a2a2a;
  border-radius: 6px;
}

.ad-slot__label {
  font-size: 0.72rem;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ad-interstitial {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ad-interstitial__panel {
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  overflow: hidden;
}

.ad-interstitial__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #222;
}

.ad-interstitial__tag {
  font-size: 0.72rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ad-interstitial__close {
  font-family: inherit;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.ad-interstitial__close:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.ad-interstitial__close:not(:disabled):hover {
  background: #222;
}

.ad-interstitial__body {
  min-height: 280px;
  padding: 1rem;
}

.ad-interstitial__footer {
  margin: 0;
  padding: 0.5rem 1rem 0.85rem;
  font-size: 0.78rem;
  color: #555;
  text-align: center;
}

/* Editor */
.editor-wrap {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 0 1.25rem;
}

.editor {
  width: 100%;
  max-width: var(--max-width);
  height: 100%;
  background: transparent;
  color: var(--fg);
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 1.18rem;
  line-height: 1.85;
  letter-spacing: -0.003em;
  caret-color: var(--fg);
  /* 타자기 모드: 현재 줄이 화면 세로 중앙에 오도록 위/아래 여백 확보 */
  padding: 45vh 0;
  overflow-y: auto;
  scroll-behavior: smooth;
  /* 타자기 모드라 현재 줄이 자동으로 중앙에 오므로
     세로 스크롤바는 숨겨 이질감을 없앤다 (휠/트랙패드 스크롤은 그대로 동작) */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/구 Edge */
}

.editor::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none; /* Chrome/Safari */
}

.editor::placeholder {
  color: var(--muted);
}

/* 텍스트 선택 색 */
::selection {
  background: var(--fg);
  color: var(--bg);
}

/* 스크롤바 최소화 */
.editor-wrap::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 600px) {
  .editor {
    font-size: 1.08rem;
  }
  .counts {
    display: none;
  }
}
