/* ==========================================================================
   juntk.site — shared theme
   ==========================================================================
   Every page on juntk.site should link this file (and theme.js) so the
   whole domain stays visually consistent as new tools get added.

   Usage in a new page's <head>:

     <script>
       try {
         var t = localStorage.getItem('juntk-theme');
         if (t === 'light' || t === 'dark') document.documentElement.setAttribute('data-theme', t);
       } catch (e) {}
     </script>
     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pretendard@1.3.9/dist/web/static/pretendard.css">
     <link rel="stylesheet" href="/theme.css">
     ... page content ...
     <script src="/theme.js" defer></script>

   The first inline snippet must come before theme.css so a returning
   visitor's saved theme applies without a flash of the wrong colors.

   Building a new page: wrap content in <div class="page">, use
   <header class="site-header"> for the title block, <div class="card-grid">
   of <a class="card"> for a menu of tools, <div class="panel"> for a form
   container, and the .btn / .field / table classes below for everything
   else. Don't invent new one-off colors — add a token here instead if the
   palette is missing something.
   ========================================================================== */

:root {
  --bg: #faf7f2;
  --bg-soft: #f2ede4;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e6ddce;
  --border-strong: #d6c9b3;
  --text: #2b241c;
  --text-dim: #746a5c;
  --text-faint: #a89a86;
  --accent: #c1603c;
  --accent-strong: #a54e2f;
  --accent-soft: rgba(193, 96, 60, 0.12);
  --accent-contrast: #fff7f0;
  --danger: #c0392b;
  --danger-soft: rgba(192, 57, 43, 0.1);
  --success: #3f7d5c;

  --shadow-sm: 0 1px 2px rgba(43, 36, 28, 0.05);
  --shadow-md: 0 12px 28px -16px rgba(43, 36, 28, 0.22);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;

  --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1815;
    --bg-soft: #221e19;
    --surface: #24201b;
    --surface-raised: #2a251f;
    --border: #3a332a;
    --border-strong: #4d4335;
    --text: #f3ece1;
    --text-dim: #b9ac98;
    --text-faint: #8a7d69;
    --accent: #e2895f;
    --accent-strong: #eda67e;
    --accent-soft: rgba(226, 137, 95, 0.16);
    --accent-contrast: #241a12;
    --danger: #e17061;
    --danger-soft: rgba(225, 112, 97, 0.14);
    --success: #6cb391;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 16px 32px -18px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #1b1815;
  --bg-soft: #221e19;
  --surface: #24201b;
  --surface-raised: #2a251f;
  --border: #3a332a;
  --border-strong: #4d4335;
  --text: #f3ece1;
  --text-dim: #b9ac98;
  --text-faint: #8a7d69;
  --accent: #e2895f;
  --accent-strong: #eda67e;
  --accent-soft: rgba(226, 137, 95, 0.16);
  --accent-contrast: #241a12;
  --danger: #e17061;
  --danger-soft: rgba(225, 112, 97, 0.14);
  --success: #6cb391;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 16px 32px -18px rgba(0, 0, 0, 0.6);
}

/* ── Reset ────────────────────────────────────────────────── */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

a { color: inherit; }

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Layout ───────────────────────────────────────────────── */

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 72px;
}

.page.page-wide { max-width: 880px; }

/* ── Header ───────────────────────────────────────────────── */

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand-eyebrow {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 6px;
}

.brand-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand-sub {
  font-size: 13.5px;
  color: var(--text-dim);
  margin-top: 6px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 14px;
  transition: color 0.15s ease;
}
.back-link:hover { color: var(--accent); }

/* ── Theme toggle ─────────────────────────────────────────── */

.theme-toggle {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

/* ── Card grid (tool menu) ────────────────────────────────── */

.card-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-eyebrow {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 8px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}

.card-desc {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── Panel (form container) ──────────────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Forms ────────────────────────────────────────────────── */

.field { margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 20px; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 7px;
}

.field-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 0.8fr;
  gap: 12px;
  margin-bottom: 12px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
}
textarea { resize: vertical; }

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--accent); color: var(--accent-contrast); width: 100%; }
.btn-primary:hover { background: var(--accent-strong); }

.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }

.btn-row { display: flex; gap: 10px; }

.search-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.search-bar input { flex: 2; min-width: 140px; }
.search-bar select { flex: 1; min-width: 120px; }
.search-bar .btn { flex-shrink: 0; padding: 0 24px; }

/* ── Badges ───────────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* ── Data table (list views) ──────────────────────────────
   Collapses into stacked cards on narrow screens. Give each
   <td> a data-label="..." matching its <th> so the mobile
   layout can show a label next to the value.
   ────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:hover { background: var(--bg-soft); }
tbody tr:last-child td { border-bottom: none; }

.row-actions { display: flex; gap: 8px; white-space: nowrap; }
.row-actions a, .row-actions button {
  font-size: 12px;
  font-weight: 600;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-dim);
}
.row-actions a:hover { color: var(--accent); border-color: var(--accent); }
.row-actions button.danger { color: var(--danger); }
.row-actions button.danger:hover { border-color: var(--danger); }

.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 44px 20px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
}

/* ── List entries (guestbook / board style posts) ────────── */

.entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.entry-title { font-size: 15px; font-weight: 700; }
.entry-meta { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }
.entry-writer { font-size: 12.5px; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.entry-body { font-size: 14px; color: var(--text-dim); line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

/* ── Footer ───────────────────────────────────────────────── */

.site-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  color: var(--text-faint);
  font-size: 12px;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 640px) {
  .page { padding: 22px 16px 56px; }
  .brand-title { font-size: 22px; }
  .panel { padding: 18px; border-radius: var(--radius-md); }
  .field-row { grid-template-columns: 1fr; gap: 12px; }
  .search-bar { flex-direction: column; }
  .search-bar input, .search-bar select, .search-bar .btn { width: 100%; }
  .btn-row { flex-direction: column; }

  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    padding: 2px 14px;
    background: var(--surface);
  }
  tbody tr:hover { background: var(--surface); }
  tbody td {
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 11px 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }
  tbody td:last-child { border-bottom: none; }
  tbody td::before {
    content: attr(data-label);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-faint);
    letter-spacing: 0.03em;
    flex-shrink: 0;
    padding-top: 2px;
  }
  tbody td.actions-cell { justify-content: flex-end; }
  tbody td.actions-cell::before { content: none; }
  .row-actions a, .row-actions button { padding: 10px 14px; font-size: 12.5px; min-height: 40px; }
}
