/* ============================================================
   딱 필요한 만큼 — 공통 스타일
   ------------------------------------------------------------
   위니브 디자인 시스템 토큰 기반.
   허브 + 모든 실습장에서 공통으로 사용.
============================================================ */

/* Pretendard variable (위니브 본가 폰트) */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable.min.css");

:root {
  /* Surface */
  --bg: #ffffff;
  --bg-soft: #f3f5fa;        /* grayLv1 — 페이지 영역 배경 */
  --bg-elev: #ffffff;
  --border: #d9dbe0;          /* grayLv2 */
  --border-soft: #e6e7ea;     /* grayLv2-lighten */

  /* Text */
  --text: #121314;            /* surface */
  --text-soft: #47494d;       /* grayLv4 */
  --text-mute: #8d9299;       /* grayLv3 */

  /* Brand */
  --accent: #2e6ff2;          /* primary */
  --accent-soft: #dee8ff;     /* activation */
  --accent-strong: #2861d2;   /* primary-a11y */
  --accent-darken: #145df0;   /* primary-darken */

  /* Semantic */
  --danger: #ff3440;          /* error */
  --success: #15bf70;         /* logo green */
  --warning: #ffc533;         /* warn */

  /* Code colors */
  --code-bg: #f3f5fa;
  --code-pink: #c93864;
  --code-purple: #964dd1;
  --code-blue: #2e5dd6;
  --code-green: #328026;
  --code-orange: #e37c00;

  --quote-border: #d9dbe0;
  --quote-bg: #f3f5fa;

  /* Effect */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 28px rgba(18, 19, 20, 0.08);

  /* Geometry */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --max-width: 1190px;
}

[data-theme="dark"] {
  --bg: #1f2123;
  --bg-soft: #121314;
  --bg-elev: #2a2c2f;
  --border: #595f66;          /* grayLv2 dark */
  --border-soft: #3b3c40;

  --text: #f3f5fa;
  --text-soft: #d9dbe0;
  --text-mute: #8d9299;

  --accent: #3075ff;
  --accent-soft: #2b3444;     /* activation dark */
  --accent-strong: #5a8eff;
  --accent-darken: #2e6ff2;

  --danger: #fc7377;
  --success: #50c140;
  --warning: #ffe187;

  --code-bg: #2a2c2f;
  --code-pink: #ed4779;
  --code-purple: #c893fd;
  --code-blue: #618dff;
  --code-green: #50c140;
  --code-orange: #ffa52a;

  --quote-border: #595f66;
  --quote-bg: #2a2c2f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 12px rgba(18, 19, 20, 0.32);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); }

/* 접근성 — 시각적으로 숨기되 스크린 리더에서는 읽힘 */
.a11y-hidden {
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  min-height: 64px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
}
.brand a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
  transition: opacity 0.15s ease;
}
.brand a:hover { opacity: 0.75; }
.brand a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.brand-logo-link { padding: 2px; }
.brand-logo {
  display: block;
  height: 26px;
  width: auto;
  flex-shrink: 0;
}
.brand .divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  display: inline-block;
}
.brand .series {
  font-size: 11px;
  letter-spacing: 0.04em;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  text-transform: uppercase;
}
.brand .title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand .home-link {
  font-size: 13px;
  color: var(--text-mute);
  margin-left: 4px;
  text-decoration: none;
  transition: color 0.15s;
}
.brand .home-link:hover { color: var(--accent); }

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.actions select,
.actions button,
.actions input[type="text"] {
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.actions select:hover,
.actions button:hover {
  background: var(--bg-soft);
  border-color: var(--text-mute);
}
.actions select:focus-visible,
.actions button:focus-visible,
.actions input[type="text"]:focus-visible {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.actions button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}
.actions button.primary:hover {
  background: var(--accent-darken);
  border-color: var(--accent-darken);
  color: #fff;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
  padding-left: 4px;
}
.theme-toggle input { accent-color: var(--accent); }

/* ---------- Split editor layout ---------- */
.split {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
}
.split.with-sidebar {
  grid-template-columns: 280px 1fr 1fr;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.pane + .pane {
  border-left: 1px solid var(--border-soft);
}

.pane-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-mute);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
  gap: 8px;
}
.pane-head .pane-actions {
  display: flex;
  gap: 6px;
}
.pane-head button {
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-soft);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.pane-head button:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.counter { font-variant-numeric: tabular-nums; }

textarea.editor {
  flex: 1;
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  padding: 20px 24px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo,
    Consolas, "D2Coding", monospace;
  font-size: 14px;
  line-height: 1.7;
  tab-size: 2;
}

.preview {
  flex: 1;
  overflow: auto;
  padding: 24px 28px 64px;
  background: var(--bg);
}

/* ---------- Bottom bar ---------- */
.bottombar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  font-size: 12px;
  color: var(--text-mute);
  background: var(--bg-soft);
  border-top: 1px solid var(--border-soft);
  gap: 12px;
  flex-wrap: wrap;
}
.bottombar em {
  color: var(--text-soft);
  font-style: normal;
  font-weight: 600;
}
.bottombar a {
  color: var(--accent);
  text-decoration: none;
}
.bottombar a:hover { text-decoration: underline; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Diagnostic strip ---------- */
.diagnostic {
  padding: 10px 16px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg-soft);
  color: var(--text-mute);
  border-top: 1px solid var(--border-soft);
  white-space: pre-wrap;
}
.diagnostic.error {
  background: rgba(255, 52, 64, 0.06);
  color: var(--danger);
  border-top-color: var(--danger);
}
.diagnostic.ok {
  color: var(--success);
}

/* ---------- Generic key-value rows ---------- */
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  font-size: 13px;
}
.kv dt {
  color: var(--text-mute);
  font-weight: 600;
}
.kv dd {
  margin: 0;
  word-break: break-all;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

/* ---------- Empty state ---------- */
.empty-state {
  padding: 32px 24px;
  color: var(--text-mute);
  font-size: 13px;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .split.with-sidebar {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr 1fr;
  }
  .pane + .pane {
    border-left: 0;
    border-top: 1px solid var(--border-soft);
  }
  .topbar { gap: 8px; padding: 12px 16px; }
  .brand { gap: 10px; }
  .brand-logo { height: 22px; }
  .brand .divider { height: 16px; }
  .brand .title { font-size: 14px; }
  .brand .series { font-size: 10px; padding: 3px 8px; }
  .actions { width: 100%; }
  .bottombar { padding: 12px 16px; }
}
