:root {
  --bg: #fbf8f4;
  --surface: #ffffff;
  --ink: #1b1b2f;
  --muted: #6b6b80;
  --line: #e9e3da;
  --primary: #e8452c;
  --primary-d: #c93620;
  --teal: #0f766e;
  --radius: 16px;
  --shadow: 0 10px 30px -12px rgba(27, 27, 47, .25);
  --font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.55; -webkit-font-smoothing: antialiased; }
img, canvas { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
.container { width: min(1120px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.inline { display: inline; margin: 0; }
[hidden] { display: none !important; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(251, 248, 244, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 50%; background: conic-gradient(var(--primary), #f59e0b, var(--teal), var(--primary)); position: relative; }
.brand-mark::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--bg); }
.nav { display: flex; align-items: center; gap: 6px; }
.nav-link { color: var(--ink); font-weight: 600; font-size: .95rem; padding: 8px 12px; border-radius: 10px; background: none; border: 0; cursor: pointer; font-family: inherit; }
.nav-link:hover, .nav-link.active { background: #f1ebe2; text-decoration: none; }

/* Buttons */
.btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 700 .95rem var(--font); padding: 12px 20px; border-radius: 12px; border: 2px solid transparent; cursor: pointer; transition: transform .1s, background .15s, box-shadow .15s; text-decoration: none !important; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -6px rgba(232, 69, 44, .6); }
.btn-primary:hover:not(:disabled) { background: var(--primary-d); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #2d2d4a; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: #f1ebe2; }
.btn-danger { background: transparent; border-color: #f3c3bb; color: #b42318; }
.btn-danger:hover { background: #fdeeeb; }
.btn-sm { padding: 8px 14px; font-size: .85rem; border-radius: 10px; }
.btn-lg { padding: 16px 24px; font-size: 1.05rem; }
.btn-block { width: 100%; }
:focus-visible { outline: 3px solid rgba(15, 118, 110, .55); outline-offset: 2px; }

/* Alerts */
.alert { margin: 16px 0 0; padding: 12px 16px; border-radius: 12px; font-weight: 500; font-size: .95rem; }
.alert-success { background: #e7f6ee; color: #166534; }
.alert-error { background: #fdeeeb; color: #b42318; }
.alert-warn { background: #fff4d6; color: #8a5a00; }

/* Hero */
.hero { padding: 56px 0 40px; background: radial-gradient(900px 400px at 85% 0%, rgba(245, 158, 11, .18), transparent 60%), radial-gradient(700px 400px at 0% 100%, rgba(15, 118, 110, .12), transparent 60%); }
.hero-in { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.hl { color: var(--primary); }
.hero p { font-size: 1.1rem; color: var(--muted); max-width: 520px; }
.pill { display: inline-block; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: .8rem; font-weight: 700; color: var(--teal); margin-bottom: 16px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 24px 0; }
.hero-stats { display: flex; gap: 32px; margin: 0; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats dt { font-size: 1.6rem; font-weight: 800; }
.hero-stats dd { margin: 0; color: var(--muted); font-size: .85rem; }
.hero-art { position: relative; height: 340px; }
.art-card { position: absolute; width: 230px; height: 230px; border-radius: 28px; box-shadow: var(--shadow); display: grid; place-items: center; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='38' r='17' fill='%23d9cfc0'/%3E%3Cpath d='M14 100c0-24 15-38 36-38s36 14 36 38z' fill='%23d9cfc0'/%3E%3C/svg%3E") center/cover; }
.art-a { left: 6%; top: 0; transform: rotate(-6deg); }
.art-b { right: 4%; bottom: 0; transform: rotate(5deg); width: 250px; height: 250px; }
.art-ring { width: 100%; height: 100%; border-radius: 28px; border: 22px solid var(--primary); box-shadow: inset 0 0 0 4px #fff; }
.art-ring.r2 { border-color: var(--teal); border-radius: 50%; }

/* Sections */
.section { padding: 40px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.search { display: flex; gap: 8px; flex-wrap: wrap; }
input[type=text], input[type=email], input[type=password], input[type=search], textarea, select, input[type=file] { font: 500 .95rem var(--font); color: var(--ink); background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 11px 14px; width: 100%; }
.search input, .search select { width: auto; padding: 8px 12px; }
.search input[type=search] { min-width: 200px; }
input:focus, textarea:focus, select:focus { border-color: var(--teal); outline: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.card { background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); color: var(--ink); transition: transform .15s, box-shadow .15s; display: block; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; }
.thumb { aspect-ratio: 1; background: #efe9df url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' fill='%23efe9df'/%3E%3Ccircle cx='50' cy='38' r='17' fill='%23d9cfc0'/%3E%3Cpath d='M14 100c0-24 15-38 36-38s36 14 36 38z' fill='%23d9cfc0'/%3E%3C/svg%3E") center/cover; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.card-body { padding: 14px 16px 16px; }
.card-body h3 { margin-bottom: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-body p { margin: 0 0 8px; font-size: .85rem; }
.count { font-size: .8rem; font-weight: 700; color: var(--teal); background: #e3f3f1; padding: 3px 10px; border-radius: 999px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 28px; }
.empty { text-align: center; padding: 56px 16px; background: var(--surface); border: 2px dashed var(--line); border-radius: var(--radius); }

.how { padding-bottom: 64px; }
.steps { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.steps b { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: #fff; margin-bottom: 12px; }
.steps p { color: var(--muted); margin: 0; }

/* Auth */
.auth { display: grid; place-items: center; padding: 48px 0; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.auth-alt { text-align: center; margin: 20px 0 0; color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: .9rem; }
.form label small { font-weight: 400; }
.form label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 600; }
.form label.check input { width: 18px; height: 18px; accent-color: var(--teal); }
.form-actions { display: flex; gap: 12px; margin-top: 4px; }

/* Create */
.create { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; padding: 40px 0 64px; align-items: start; }
.create-preview { position: sticky; top: 88px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.preview-stage { aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; text-align: center; padding: 8px; background: #efe9df url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='38' r='17' fill='%23d9cfc0'/%3E%3Cpath d='M14 100c0-24 15-38 36-38s36 14 36 38z' fill='%23d9cfc0'/%3E%3C/svg%3E") center/cover; }
.preview-stage img { width: 100%; height: 100%; object-fit: contain; }
#previewNote.err { color: #b42318; font-weight: 600; }
.tips { margin-top: 12px; font-size: .9rem; }
.tips summary { cursor: pointer; font-weight: 700; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat span { display: block; color: var(--ink); font-size: 1.8rem; font-weight: 800; }
.list { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px 12px 12px; }
.thumb-sm { width: 84px; flex: none; border-radius: 10px; overflow: hidden; }
.row-main { flex: 1; min-width: 0; }
.row-main h3 { margin: 0; }
.row-main h3 a { color: var(--ink); }
.row-main p { margin: 2px 0 0; }
.row-stats { font-size: .9rem; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.row-actions form { margin: 0; }
.badge { font-size: .7rem; background: #fff4d6; color: #8a5a00; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }

/* Editor */
.editor-wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr); gap: 40px; padding: 32px 0 64px; align-items: start; }
.stage { position: relative; width: 100%; max-width: min(640px, calc((100vh - 130px) * var(--ar, 1))); min-width: min(100%, 280px); margin-inline: auto; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); background: #e8e3da; }
.stage.drag { outline: 4px dashed var(--teal); outline-offset: -4px; }
#cv { width: 100%; height: auto; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
#cv.grabbing { cursor: grabbing; }
.stage-hint { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; font-size: .9rem; font-weight: 600; color: #fff; text-shadow: 0 1px 4px rgba(0, 0, 0, .55); }
.stage-hint .btn { pointer-events: auto; text-shadow: none; }
.stage-col .small { margin-top: 12px; }
.panel h1 { font-size: 1.7rem; }
.by { font-size: .9rem; }
.desc { color: #3b3b52; }
.ctrl-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; display: flex; flex-direction: column; gap: 14px; }
.slider { display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 10px; font-size: .85rem; font-weight: 700; }
input[type=range] { width: 100%; accent-color: var(--primary); }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.caption-box { margin-top: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.caption-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.caption-box pre { margin: 0; white-space: pre-wrap; font: inherit; font-size: .92rem; color: #3b3b52; }
.share { margin-top: 20px; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { font: 600 .85rem var(--font); background: var(--surface); border: 1px solid var(--line); color: var(--ink); padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.chip:hover { background: #f1ebe2; text-decoration: none; }
.privacy { margin-top: 20px; }

/* Footer */
.footer { border-top: 1px solid var(--line); padding: 28px 0; background: #f5efe6; font-size: .9rem; }
.footer-in { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Responsif */
@media (max-width: 860px) {
  .hero-in, .create, .editor-wrap { grid-template-columns: 1fr; }
  .hero-art { display: none; }
  .steps { grid-template-columns: 1fr; }
  .create-preview { position: static; }
  .editor-wrap { gap: 24px; padding-top: 16px; }
}
@media (max-width: 560px) {
  .nav .nav-link:first-child { display: none; }
  .topbar-in { height: auto; min-height: 56px; flex-wrap: wrap; padding: 8px 0; }
  .nav { flex-wrap: wrap; justify-content: flex-end; gap: 2px; }
  .nav-link { padding: 6px 8px; font-size: .88rem; }
  .row { flex-wrap: wrap; }
  .row-actions { width: 100%; justify-content: flex-start; }
  .stats { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; }
  .stat span { font-size: 1.3rem; }
  .auth-card { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
