@layer reset, site, wiki;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
  ul, ol { padding-left: 1.2em; }
  button, input, select, textarea { font: inherit; }
}

@layer site {
  :root {
    color-scheme: light;
    --site-bg: #f4f5f7;
    --site-paper: #ffffff;
    --site-text: #1f2328;
    --site-muted: #6b7280;
    --site-line: #dfe3e8;
    --site-brand: #0f766e;
    --site-brand-ink: #ffffff;
    --site-link: #0a6b9e;
    --site-danger: #b42318;
    --site-ok: #12703f;
    --site-ok-bg: #e7f6ee;
    --site-error-bg: #fdecea;
    --site-warn-bg: #fff4d6;
    --site-add-bg: #e3f6e8;
    --site-del-bg: #fde7e7;
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --site-bg: #14171a; --site-paper: #1c2024; --site-text: #e4e6ea; --site-muted: #98a0ab;
    --site-line: #2f353b; --site-brand: #14a398; --site-link: #6cb8e6; --site-danger: #ff7b7b; --site-ok: #5fd08f;
    --site-ok-bg: #16322a; --site-error-bg: #3a1d1b; --site-warn-bg: #3a3118; --site-add-bg: #16342b; --site-del-bg: #3a1f22;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;
      --site-bg: #14171a; --site-paper: #1c2024; --site-text: #e4e6ea; --site-muted: #98a0ab;
      --site-line: #2f353b; --site-brand: #14a398; --site-link: #6cb8e6; --site-danger: #ff7b7b; --site-ok: #5fd08f;
      --site-ok-bg: #16322a; --site-error-bg: #3a1d1b; --site-warn-bg: #3a3118; --site-add-bg: #16342b; --site-del-bg: #3a1f22;
    }
  }

  body {
    background: var(--site-bg);
    color: var(--site-text);
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
    line-height: 1.7;
    font-size: 15.5px;
  }
  a { color: var(--site-link); text-decoration: none; }
  a:hover { text-decoration: underline; }
  :focus-visible { outline: 2px solid var(--site-brand); outline-offset: 2px; }
  [hidden] { display: none !important; }

  /* ---------- 헤더 ---------- */
  .site-header { background: var(--site-brand); color: var(--site-brand-ink); position: relative; z-index: 10; }
  .site-header__inner {
    max-width: 1100px; margin: 0 auto; padding: 8px 16px; min-height: 56px;
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  }
  .site-logo { color: var(--site-brand-ink); font-weight: 800; font-size: 20px; white-space: nowrap; }
  .site-logo span { font-weight: 500; opacity: .85; }
  .site-logo:hover { text-decoration: none; }
  .site-search { position: relative; flex: 1 1 200px; max-width: 360px; }
  .site-search input {
    width: 100%; padding: 7px 12px; border-radius: 999px; border: 0;
    background: rgba(255, 255, 255, .92); color: #1f2328;
  }
  .suggest {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px 0; list-style: none;
    background: var(--site-paper); color: var(--site-text); border: 1px solid var(--site-line); border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18); max-height: 320px; overflow-y: auto;
  }
  .suggest li { padding: 6px 14px; cursor: pointer; }
  .suggest li.is-active, .suggest li:hover { background: var(--site-bg); }
  .suggest mark { background: transparent; color: var(--site-brand); font-weight: 700; }
  .nav-toggle {
    display: none; margin-left: auto; background: rgba(255, 255, 255, .16); color: var(--site-brand-ink);
    border: 1px solid rgba(255, 255, 255, .5); border-radius: 6px; padding: 5px 10px; cursor: pointer;
  }
  .site-menu { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-left: auto; }
  .site-nav { display: flex; gap: 14px; flex-wrap: wrap; }
  .site-nav a, .site-user a, .site-user .link-button, .site-user .icon-button { color: var(--site-brand-ink); }
  .site-user { display: flex; align-items: center; gap: 12px; }
  .site-user form { margin: 0; }
  .link-button { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
  .icon-button { background: none; border: 0; padding: 2px 4px; cursor: pointer; font-size: 1.05rem; }
  .bell { position: relative; display: inline-block; padding: 2px 4px; color: var(--site-brand-ink); }
  .toolbar__right { margin-left: auto; }
  .nowrap { white-space: nowrap; }
  .bell__count {
    position: absolute; top: -6px; right: -8px; min-width: 18px; padding: 0 5px; border-radius: 9px;
    background: #d92d20; color: #fff; font-size: .72rem; line-height: 18px; text-align: center; font-weight: 700;
  }

  @media (max-width: 760px) {
    .nav-toggle { display: inline-block; }
    .site-search { order: 5; flex-basis: 100%; max-width: none; }
    .site-menu { display: none; flex-direction: column; align-items: flex-start; width: 100%; margin: 0; order: 6; }
    .site-menu.is-open { display: flex; }
    .site-nav, .site-user { flex-direction: column; align-items: flex-start; }
  }

  /* ---------- 페이지 ---------- */
  .page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
  .page--narrow { max-width: 520px; }
  .page h1 { font-size: 1.6rem; margin-bottom: 14px; line-height: 1.35; }
  .page h2 { font-size: 1.15rem; margin: 28px 0 10px; }
  .page__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; margin-bottom: 8px; }
  .page__head h1 { margin: 0; }
  .actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
  .muted { color: var(--site-muted); }
  p.muted, .page > .muted { margin-top: 12px; }
  .hint { font-size: .85rem; color: var(--site-muted); min-height: 1.2em; }
  .hint--ok { color: var(--site-ok); }
  .hint--error { color: var(--site-danger); }
  .empty { padding: 28px 12px; text-align: center; color: var(--site-muted); background: var(--site-paper);
    border: 1px dashed var(--site-line); border-radius: 8px; }

  /* ---------- 폼 ---------- */
  .form { display: grid; gap: 14px; background: var(--site-paper); border: 1px solid var(--site-line); border-radius: 8px; padding: 18px; }
  .form--inline { display: flex; flex-wrap: wrap; align-items: end; margin-bottom: 20px; }
  .form--flat { background: none; border: 0; padding: 0; }
  .form label { display: grid; gap: 4px; font-size: .92rem; }
  .form input[type=text], .form input[type=email], .form input[type=password], .form input[type=number],
  .form input[type=search], .form select, .form textarea, .input {
    padding: 9px 10px; border: 1px solid var(--site-line); border-radius: 6px;
    background: var(--site-bg); color: var(--site-text); width: 100%;
  }
  .form--inline input[type=number] { width: 110px; }
  .form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; line-height: 1.55; resize: vertical; }
  .check { display: flex !important; align-items: center; gap: 8px; }
  .field-error { color: var(--site-danger); font-size: .85rem; }
  .rules { border: 1px solid var(--site-line); border-radius: 6px; padding: 10px 14px; font-size: .9rem; }
  .rules h2 { font-size: 1rem; margin: 0 0 4px; }

  .btn {
    display: inline-block; padding: 8px 15px; border-radius: 6px; cursor: pointer; line-height: 1.4;
    border: 1px solid var(--site-line); background: var(--site-paper); color: var(--site-text);
  }
  .btn:hover { text-decoration: none; border-color: var(--site-muted); }
  .btn--primary { background: var(--site-brand); border-color: var(--site-brand); color: var(--site-brand-ink); }
  .btn--danger { color: var(--site-danger); border-color: var(--site-danger); }
  .btn--small { padding: 3px 10px; font-size: .85rem; }

  .flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
  .flash--ok { background: var(--site-ok-bg); }
  .flash--error { background: var(--site-error-bg); color: var(--site-danger); }
  .flash--warn { background: var(--site-warn-bg); }
  .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }

  .meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin-bottom: 8px; }
  .meta dt { color: var(--site-muted); }

  /* ---------- 표·목록·배지 ---------- */
  .table-wrap { overflow-x: auto; }
  .table { width: 100%; border-collapse: collapse; background: var(--site-paper); }
  .table th, .table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--site-line); }
  .table--nowrap th, .table--nowrap td { white-space: nowrap; }
  .table .actions { display: flex; gap: 6px; }
  .table .is-withdrawn { color: var(--site-muted); }
  form.inline { display: inline; margin: 0; }

  .list { list-style: none; padding: 0; margin: 0; background: var(--site-paper); border: 1px solid var(--site-line); border-radius: 8px; }
  .list__item { padding: 11px 14px; border-bottom: 1px solid var(--site-line); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
  .list__item:last-child { border-bottom: 0; }
  .list__title { font-weight: 600; }
  .list__meta { color: var(--site-muted); font-size: .85rem; margin-left: auto; }
  .list__sub { flex-basis: 100%; color: var(--site-muted); font-size: .88rem; }
  .list__sub mark { background: var(--site-warn-bg); color: inherit; padding: 0 1px; }

  .badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .78rem; line-height: 1.7;
    border: 1px solid var(--site-line); background: var(--site-paper); color: var(--site-muted); white-space: nowrap; }
  .badge--ok { border-color: var(--site-ok); color: var(--site-ok); }
  .badge--danger { border-color: var(--site-danger); color: var(--site-danger); }
  .badge--warn { background: var(--site-warn-bg); color: var(--site-text); }
  .badge--brand { border-color: var(--site-brand); color: var(--site-brand); }

  .tabs-nav { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--site-line); margin-bottom: 14px; }
  .tabs-nav a { padding: 8px 14px; border-radius: 6px 6px 0 0; color: var(--site-muted); }
  .tabs-nav a[aria-current="page"] { color: var(--site-text); font-weight: 700; border-bottom: 2px solid var(--site-brand); }
  .tabs-nav a:hover { text-decoration: none; background: var(--site-paper); }

  .pager { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }

  .notice { background: var(--site-paper); border: 1px solid var(--site-line); border-left: 4px solid var(--site-brand);
    border-radius: 6px; padding: 10px 14px; margin: 12px 0; }
  .notice--warn { border-left-color: #d9a400; background: var(--site-warn-bg); }
  .notice--danger { border-left-color: var(--site-danger); }

  .toc { background: var(--site-paper); border: 1px solid var(--site-line); border-radius: 8px; padding: 10px 16px; margin: 12px 0; font-size: .92rem; }
  .toc ol { list-style: none; padding-left: 0; }
  .toc .toc__l3 { padding-left: 1.1em; }
  .toc .toc__l4 { padding-left: 2.2em; }

  /* ---------- 에디터 ---------- */
  .toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; background: var(--site-paper);
    border: 1px solid var(--site-line); border-radius: 8px 8px 0 0; border-bottom: 0; }
  .toolbar .btn { padding: 3px 10px; font-size: .85rem; }
  .toolbar input[type=color] { width: 34px; height: 28px; padding: 0; border: 1px solid var(--site-line); background: none; }
  .toolbar__sep { width: 1px; height: 22px; background: var(--site-line); }
  .editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .editor-grid .pane-title { font-size: .85rem; color: var(--site-muted); margin-bottom: 4px; }
  .preview { background: var(--site-paper); border: 1px solid var(--site-line); border-radius: 8px; padding: 14px 16px;
    min-height: 240px; overflow-wrap: anywhere; }
  .warnings { margin: 6px 0 0; padding-left: 1.2em; color: var(--site-danger); font-size: .88rem; }
  #byte-counter.is-over { color: var(--site-danger); font-weight: 700; }
  @media (max-width: 860px) { .editor-grid { grid-template-columns: 1fr; } }

  /* ---------- diff ---------- */
  .diff { background: var(--site-paper); border: 1px solid var(--site-line); border-radius: 8px; overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; line-height: 1.5; }
  .diff-line { display: flex; white-space: pre-wrap; overflow-wrap: anywhere; }
  .diff-line__sign { flex: 0 0 2em; text-align: center; color: var(--site-muted); user-select: none; }
  .diff-line__text { flex: 1; padding-right: 8px; }
  .diff-line--add { background: var(--site-add-bg); }
  .diff-line--del { background: var(--site-del-bg); }
  .diff-line--add .diff-line__sign { color: var(--site-ok); font-weight: 700; }
  .diff-line--del .diff-line__sign { color: var(--site-danger); font-weight: 700; }

  /* ---------- 제안 상세 ---------- */
  .tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--site-line); margin-top: 18px; }
  .tabbar [role="tab"] { background: none; border: 0; padding: 8px 14px; cursor: pointer; color: var(--site-muted);
    border-bottom: 2px solid transparent; }
  .tabbar [role="tab"][aria-selected="true"] { color: var(--site-text); font-weight: 700; border-bottom-color: var(--site-brand); }
  .tabpanel { padding-top: 14px; }
  .review { background: var(--site-paper); border: 1px solid var(--site-line); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
  .review--old { opacity: .6; }
  .review__head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: .9rem; }
  .review__body { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
  .checklist { margin: 8px 0 0; }
  .progress { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; background: var(--site-paper);
    border: 1px solid var(--site-line); border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
  .progress strong { font-size: 1.1rem; }
  .panel { background: var(--site-paper); border: 1px solid var(--site-line); border-radius: 8px; padding: 14px; margin: 10px 0; }
  .panel > summary { cursor: pointer; font-weight: 600; }
  .panel form { margin-top: 10px; }
  .grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
  .versions-select { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
}
