:root {
  --red: #d13139;
  --red-dark: #a8242b;
  --red-soft: #fbeaea;
  --ink: #1d1d1f;
  --ink-2: #4a4a50;
  --muted: #76767e;
  --line: #e4e4e8;
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #fafafb;
  --jira: #0c66e4;
  --jira-soft: #e9f2ff;
  --ok: #1f7a46;
  --ok-soft: #e6f4ec;
  --shadow: 0 1px 2px rgba(20, 20, 30, .06), 0 4px 16px rgba(20, 20, 30, .05);
  --radius: 10px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Archivo", var(--font);
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --red-soft: #3a1c1e;
    --ink: #f1f1f3;
    --ink-2: #c9c9cf;
    --muted: #9a9aa3;
    --line: #2f2f36;
    --bg: #141417;
    --surface: #1c1c20;
    --surface-2: #222227;
    --jira: #85b8ff;
    --jira-soft: #1c2b41;
    --ok: #7ee2a8;
    --ok-soft: #173325;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 .6em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.mt { margin-top: 12px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--display); font-size: 17px; }
.brand b { color: var(--red); font-weight: 700; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--red); color: #fff;
  font: 700 16px var(--display); flex: none; }
.brand-mark-lg { width: 48px; height: 48px; font-size: 26px; border-radius: 12px; margin-bottom: 14px; }
.nav { display: flex; align-items: center; gap: 18px; }
.nav > a:not(.btn) { text-decoration: none; color: var(--ink-2); font-weight: 500; }
.nav > a:not(.btn):hover { color: var(--red); }
.usermenu { position: relative; }
.usermenu summary { white-space: nowrap; cursor: pointer; list-style: none; font-weight: 500; color: var(--ink-2); }
.usermenu summary::after { content: " ▾"; font-size: 11px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-pop { position: absolute; right: 0; top: 30px; min-width: 220px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; display: grid; gap: 8px; }
.usermenu-pop a { text-decoration: none; }

.wrap { max-width: 860px; margin: 0 auto; padding: 28px 24px 60px; }
.wrap-wide { max-width: 1480px; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 500 14px var(--font); cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-google { width: 100%; padding: 11px; font-size: 15px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--ink-2); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linkbtn:hover { color: var(--red); }

label { display: block; font-weight: 500; font-size: 14px; }
label > input:not([type=checkbox]), label > textarea, label > select { display: block; margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input:not([type]), textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: 400 14px var(--font); }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus, .btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--red) 55%, transparent); outline-offset: 1px; border-color: var(--red); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.stack { display: grid; gap: 14px; }
.narrow { max-width: 420px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.back { display: inline-block; text-decoration: none; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.back:hover { color: var(--red); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--red-soft); color: var(--red); }

/* login */
.login { display: grid; place-items: center; min-height: 70vh; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px; box-shadow: var(--shadow); text-align: center; }
.login-card form { text-align: left; margin-top: 8px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 18px 0 6px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* library */
.lib-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; }
.search { display: flex; gap: 8px; min-width: min(420px, 100%); }
.tagbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.sortbar { margin-bottom: 18px; }
.sortbar a { margin-left: 8px; text-decoration: none; }
.sortbar a.on { color: var(--ink); font-weight: 600; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); font-size: 12px; text-decoration: none; color: var(--ink-2); line-height: 1.6; }
a.tag:hover { border-color: var(--muted); }
.tag-jira { background: var(--jira-soft); border-color: transparent; color: var(--jira); font-family: var(--mono); font-weight: 500; }
.tag-on { background: var(--red); border-color: var(--red); color: #fff; }
.tag-clear { color: var(--red); border-color: var(--red); background: transparent; }
.tag-n { opacity: .65; }
.tag-group { display: inline-flex; align-items: center; }
.tag-ext { text-decoration: none; color: var(--jira); font-size: 12px; padding: 0 6px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; text-decoration: none; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; min-height: 170px; }
.card:hover { border-color: var(--red); transform: translateY(-1px); }
.card h3 { margin: 0; font-size: 17px; }
.card-top { display: flex; gap: 6px; align-items: center; }
.card-notes { color: var(--ink-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.card-meta { margin-top: auto; }
.vbadge { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--ink); color: var(--surface); font: 600 11px var(--mono); }
.pill { font-size: 11px; padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.pill-share { background: var(--ok-soft); color: var(--ok); }
.empty { text-align: center; padding: 60px 20px; }

/* dropzone */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px; text-align: center; background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--red); background: var(--red-soft); }
.dz-icon { font-size: 28px; color: var(--red); line-height: 1; margin-bottom: 6px; }
.dz-actions { display: flex; justify-content: center; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.dz-list { margin-top: 8px; word-break: break-all; }
.progress { position: relative; height: 26px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.progress-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: color-mix(in srgb, var(--red) 25%, transparent); transition: width .2s; }
.progress span { position: relative; display: block; text-align: center; line-height: 24px; }

/* mockup page */
.mk-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.mk-title h1 { margin-bottom: 6px; }
.mk-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.mk-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.vselect { width: auto; max-width: 280px; }
.mk-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.stage-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); gap: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 12px; font: 500 13px var(--font); color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: var(--surface); }
.stage-frame { background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--bg) 0 50%) 0 0 / 16px 16px; display: flex; justify-content: center; }
.stage-frame iframe { display: block; width: 100%; height: calc(100vh - 230px); min-height: 520px; border: 0; background: #fff; transition: width .25s; }
.side { display: grid; gap: 16px; }
.side-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; max-height: 340px; overflow: auto; }
.history li { padding: 7px 8px; border-radius: 7px; }
.history li.on { background: var(--red-soft); }
.history a { display: flex; gap: 8px; align-items: center; text-decoration: none; }
.history p { margin: 4px 0 0; color: var(--ink-2); white-space: pre-wrap; }
.danger summary { cursor: pointer; color: var(--red); }
.danger form { margin-top: 8px; }

dialog.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.dlg::backdrop { background: rgba(15, 15, 20, .45); }
.copyrow { display: flex; gap: 8px; }
.copyrow input { font-family: var(--mono); font-size: 13px; }

/* admin */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--muted); font-size: 13px; box-shadow: var(--shadow); }
.stat span { display: block; font: 700 24px var(--display); color: var(--ink); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.tbl tr.inactive td { color: var(--muted); }
.tbl-actions { display: flex; gap: 12px; justify-content: flex-end; }
details > summary { cursor: pointer; font-weight: 500; }

/* public viewer */
body.public-view { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.pv-bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.pv-bar strong { font-family: var(--display); }
.pv-open { margin-left: auto; }
.pv-frame { flex: 1; width: 100%; border: 0; background: #fff; }

@media (max-width: 1000px) {
  .mk-body { grid-template-columns: 1fr; }
  .stage-frame iframe { height: 70vh; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .nav { gap: 12px; }
  .nav > a:first-child { display: none; }
  .brand > span:last-child { display: none; }
  .wrap { padding: 20px 16px 48px; }
  .row2 { grid-template-columns: 1fr; }
  .tbl { display: block; overflow-x: auto; }
  .pv-bar .muted { display: none; }
}
