:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #2d2a26;
  --muted: #8a8378;
  --brand: #b0846a;
  --brand-dark: #8f6850;
  --line: #eae4da;
  --ok: #3f8f5f;
  --danger: #c0554d;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(60, 45, 30, .08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); min-height: 100vh;
}
a { color: var(--brand-dark); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 10px; padding: 11px 18px; font-size: 14px; font-weight: 600;
  background: var(--brand); color: #fff; transition: .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #eecfcc; }
.btn.danger:hover { background: #fdf3f2; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--brand); border-color: transparent; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 36px 32px; width: 100%; max-width: 420px; }
.logo { font-family: 'Cormorant Garamond', serif; font-size: 30px; text-align: center; margin-bottom: 4px; }
.logo em { color: var(--brand); font-style: normal; }
.tagline { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.tabs button { flex: 1; border: none; background: transparent; padding: 9px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.topbar {
  background: #fff; border-bottom: 1px solid var(--line); padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50;
}
.topbar .logo { font-size: 22px; margin: 0; }
.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.page-head h1 { font-size: 22px; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 4px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.project-card .cover { height: 110px; border-radius: 10px; margin-bottom: 14px; background-size: cover; background-position: center; }
.project-card h3 { font-size: 17px; margin-bottom: 2px; }
.project-card .meta { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.project-card .stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.project-card .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.published { background: #e5f4ea; color: var(--ok); }
.badge.draft { background: #f3efe8; color: #9a8f7d; }

.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 12px; }

.modal-bg { position: fixed; inset: 0; background: rgba(30,25,20,.45); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 18px; padding: 26px; width: 100%; max-width: 720px; max-height: 88vh; overflow: auto; }
.modal h2 { margin-bottom: 16px; font-size: 19px; }

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 10px 0 18px; }
.tpl-item { border: 2px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; background: #fff; transition: .15s; }
.tpl-item:hover { transform: translateY(-2px); }
.tpl-item.selected { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(176,132,106,.2); }
.tpl-item .thumb { height: 90px; background-size: cover; background-position: center; }
.tpl-item .name { padding: 8px 10px 2px; font-weight: 700; font-size: 13px; }
.tpl-item .desc { padding: 0 10px 10px; font-size: 11px; color: var(--muted); line-height: 1.4; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; }
.toast.show { opacity: 1; }

.error-msg { background: #fdf3f2; color: var(--danger); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; display: none; }
.error-msg.show { display: block; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* editor */
.editor-layout { display: grid; grid-template-columns: 1fr 380px; gap: 22px; align-items: start; }
@media (max-width: 960px) { .editor-layout { grid-template-columns: 1fr; } .preview-col { display: none; } }
.section-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.section-card > summary { padding: 16px 20px; font-weight: 700; font-size: 15px; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.section-card > summary::after { content: '▾'; color: var(--muted); }
.section-card[open] > summary::after { content: '▴'; }
.section-card .body { padding: 0 20px 20px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
.preview-col { position: sticky; top: 84px; }
.preview-frame { width: 100%; aspect-ratio: 9/17; border: 8px solid #2d2a26; border-radius: 28px; background: #fff; }
.gallery-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.gallery-list .g-item { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; }
.gallery-list .g-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-list .g-item button { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 6px; width: 22px; height: 22px; font-size: 12px; }
.acc-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; margin-bottom: 8px; }
