/* Audnora design language: warm paper background, deep teal + copper, DM Serif Display / DM Sans, pill buttons */
:root {
  --bg: #faf8f4;
  --bg-alt: #f0eee9;
  --surface: #fffdfa;
  --ink: #202624;
  --muted: #5d6a66;
  --line: #e2dfd6;
  --teal: #145c59;
  --teal-dark: #073b3b;
  --teal-soft: #e3eeec;
  --copper: #b36d49;
  --copper-soft: #f6e9e1;
  --danger: #a6392f;
  --danger-soft: #f8e5e2;
  --ok: #1f7a4d;
  --shadow: 0 1px 2px #07302d0d, 0 8px 24px #07302d0f;
  --shadow-lg: 0 2px 4px #07302d12, 0 18px 44px #07302d1f;
  --radius: 16px;
  --radius-sm: 12px;
  --font: 'DM Sans', system-ui, sans-serif;
  --serif: 'DM Serif Display', Georgia, serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.55; -webkit-font-smoothing: antialiased; }
body:not(.login-page) { min-height: 100vh; display: flex; flex-direction: column; }
body:not(.login-page) > main { flex: 1; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; line-height: 1.15; color: var(--teal-dark); }
.container { width: min(1160px, 100% - 48px); margin: 0 auto; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid #b36d4966; outline-offset: 2px; }
svg.i { width: 1em; height: 1em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Header */
.nav-shell { position: sticky; top: 0; z-index: 30; background: #faf8f4f2; border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); }
.nav { min-height: 64px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 50%; background: var(--teal); display: grid; place-items: center; color: #fff; font-family: var(--serif); font-size: 19px; position: relative; }
.brand-mark::after { content: ''; position: absolute; right: -1px; top: 3px; width: 9px; height: 9px; border-radius: 50%; background: var(--copper); border: 2px solid var(--bg); }
.brand-name { font-family: var(--serif); font-size: 24px; color: var(--teal-dark); }
.brand-sep { width: 1px; height: 22px; background: var(--line); }
.brand-title { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.nav-links { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.nav-email { font-size: 13px; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 700 14px/1 var(--font); padding: 12px 20px; border-radius: 50px; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; transition: .18s ease; white-space: nowrap; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-outline { background: transparent; color: var(--teal); border-color: var(--teal); }
.btn-outline:hover { background: var(--teal-soft); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-alt); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-sm { padding: 9px 15px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: inline-grid; place-items: center; cursor: pointer; font-size: 16px; transition: .15s; }
.icon-btn:hover:not([disabled]) { background: var(--teal-soft); color: var(--teal); border-color: var(--teal-soft); }
.icon-btn.danger:hover:not([disabled]) { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }
.icon-btn[disabled] { opacity: .35; cursor: not-allowed; }

/* Hero */
.hero { background: radial-gradient(ellipse at 85% 30%, #eee5da 0%, transparent 50%), var(--bg); padding: 34px 0 22px; text-align: center; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--copper); background: var(--copper-soft); padding: 6px 13px; border-radius: 50px; }
.hero h1 { font-size: clamp(32px, 4.8vw, 52px); margin: 12px 0 10px; }
.hero h1 em { color: var(--copper); font-style: italic; }
.hero p { max-width: 600px; margin: 0 auto 20px; color: var(--muted); font-size: 16.5px; }
.search { position: relative; max-width: 600px; margin: 0 auto; }
.search > .i { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 19px; pointer-events: none; }
.search input { width: 100%; padding: 14px 48px; font: 500 15.5px var(--font); border-radius: 50px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px #145c5922; }
.search .clear { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.chip { font-size: 13px; font-weight: 600; padding: 5px 13px; border-radius: 50px; background: var(--teal-soft); color: var(--teal); }

/* Tool cards */
.listing { padding: 8px 0 72px; }
.listing-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; color: var(--muted); font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 480px), 1fr)); gap: 20px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; transition: box-shadow .2s, transform .2s; border-top: 4px solid var(--teal); }
.card:hover { box-shadow: var(--shadow-lg); }
.card-head { display: flex; gap: 12px; align-items: center; }
.card-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--teal); color: #fff; display: grid; place-items: center; font-family: var(--serif); font-size: 21px; flex: none; }
.card h2 { flex: 1; min-width: 0; font-size: 24px; }
.card h2 a { text-decoration: none; }
.card h2 a:hover { color: var(--teal); text-decoration: underline; text-decoration-color: var(--copper); text-underline-offset: 5px; }
.badge { flex: none; margin-left: auto; font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: 50px; background: var(--copper-soft); color: var(--copper); white-space: nowrap; }
.desc { margin: 0; color: var(--muted); font-size: 15px; }
.pointers { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pointers li { display: flex; gap: 10px; font-size: 14.5px; }
.pointers li::before { content: ''; flex: none; width: 7px; height: 7px; margin-top: 8px; border-radius: 50%; background: var(--copper); }
.card-body, .child-body { display: flex; flex-direction: column; gap: 12px; position: relative; }
.card-body.is-clamped, .child-body.is-clamped { max-height: 168px; overflow: hidden; }
.card-body.is-clamped::after, .child-body.is-clamped::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 44px; pointer-events: none; }
.card-body.is-clamped::after { background: linear-gradient(to bottom, transparent, var(--surface) 90%); }
.child-body.is-clamped::after { background: linear-gradient(to bottom, transparent, var(--bg) 90%); }
.read-more { align-self: flex-start; background: none; border: none; padding: 0; margin-top: -4px; font: 700 13px var(--font); color: var(--teal); cursor: pointer; }
.read-more:hover { color: var(--teal-dark); text-decoration: underline; text-underline-offset: 3px; }
.card-actions { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
mark { background: #f1d3bf; color: inherit; border-radius: 3px; padding: 0 2px; }

.children { border-top: 1px dashed var(--line); padding-top: 14px; margin-top: 2px; }
.toggle { font-weight: 700; margin-left: auto; }
.toggle .i { transition: transform .2s; }
.toggle[aria-expanded="true"] .i { transform: rotate(180deg); }
.child-grid { display: grid; gap: 10px; }
.child { background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: var(--radius-sm); padding: 14px 16px; display: grid; gap: 8px; }
.child-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.child h3 { font-family: var(--font); font-weight: 700; font-size: 15px; color: var(--ink); display: flex; gap: 8px; align-items: center; min-width: 0; flex: 1; word-break: break-word; }
.child h3 .i { color: var(--copper); }
.child h3 a { text-decoration: none; }
.child h3 a:hover { color: var(--teal); text-decoration: underline; }
.child .btn { flex: none; }

.empty { text-align: center; padding: 70px 20px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty .ring { width: 64px; height: 64px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; margin: 0 auto 16px; font-size: 28px; }
.empty h3 { font-size: 26px; margin-bottom: 6px; }
.empty p { color: var(--muted); margin: 0 0 18px; }
.skeleton { height: 240px; border-radius: var(--radius); background: linear-gradient(90deg, var(--bg-alt), #f7f5f0, var(--bg-alt)); background-size: 200% 100%; animation: sh 1.3s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

.footer { margin-top: auto; background: var(--teal-dark); color: #cfe0dd; padding: 28px 0; font-size: 14px; }
.footer .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer a { color: #fff; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 80% 20%, #eee5da 0%, transparent 50%), var(--bg); }
.login-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 38px; }
.login-card .brand { margin-bottom: 22px; }
.login-card h1 { font-size: 34px; }
.login-card .sub { color: var(--muted); margin: 6px 0 22px; }
.alert { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 600; margin-bottom: 16px; }

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label, .label { font-size: 13px; font-weight: 700; color: var(--teal-dark); }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
input[type=text], input[type=url], input[type=email], input[type=password], textarea { width: 100%; font: 500 15px var(--font); padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--ink); }
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px #145c5922; }
.field.has-error input, .field.has-error textarea { border-color: var(--danger); }
.err { color: var(--danger); font-size: 12.5px; font-weight: 600; min-height: 0; }
.ptr-row { display: flex; gap: 8px; margin-bottom: 8px; }
.ptr-row input { flex: 1; }

/* Admin */
.admin-bar { padding: 36px 0 18px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.admin-bar h1 { font-size: clamp(30px, 4vw, 42px); }
.admin-bar p { margin: 4px 0 0; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 8px 0 26px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px 18px; }
.kpi b { display: block; font-family: var(--serif); font-weight: 400; font-size: 34px; color: var(--teal); line-height: 1; }
.kpi span { font-size: 13px; color: var(--muted); }
.admin-list { display: grid; gap: 16px; padding-bottom: 80px; }
.node { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.node.inactive { opacity: .72; background: var(--bg-alt); }
.node-row { display: flex; gap: 14px; align-items: center; padding: 16px 18px; flex-wrap: wrap; }
.node-main { flex: 1 1 260px; min-width: 0; }
.node-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.node-title strong { font-size: 17px; word-break: break-word; }
.node.parent > .node-row { border-left: 4px solid var(--teal); }
.node-sub { font-size: 13px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 50px; background: var(--teal-soft); color: var(--teal); }
.pill.off { background: #e6e3db; color: var(--muted); }
.pill.cu { background: var(--copper-soft); color: var(--copper); }
.node-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sub-list { background: var(--bg); border-top: 1px solid var(--line); padding: 12px 18px 16px 34px; display: grid; gap: 10px; }
.sub-list .node { box-shadow: none; }
.sub-list .node-row { padding: 12px 14px; }
.sub-empty { color: var(--muted); font-size: 14px; margin: 0; }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 2; }
.switch span { position: absolute; inset: 0; background: #cfcdc3; border-radius: 50px; transition: .2s; }
.switch span::after { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px #0003; }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid #b36d4966; outline-offset: 2px; }

/* Modal + toast */
.modal-back { position: fixed; inset: 0; background: #07302d80; backdrop-filter: blur(3px); z-index: 60; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 20px; width: min(600px, 100%); box-shadow: var(--shadow-lg); padding: 30px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal h2 { font-size: 30px; margin-bottom: 4px; }
.modal .sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.radio-card { display: flex; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.radio-card small { display: block; color: var(--muted); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 10px; max-width: calc(100vw - 40px); }
.toast { background: var(--teal-dark); color: #fff; padding: 13px 18px; border-radius: 14px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: 14px; display: flex; gap: 10px; align-items: center; animation: up .25s ease; }
.toast.error { background: var(--danger); }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

@media (max-width: 860px) {
  .container { width: min(100% - 32px, 1160px); }
  .hero { padding: 26px 0 18px; }
  .brand-sep, .brand-title, .nav-email { display: none; }
}
@media (max-width: 560px) {
  .card { padding: 18px; }
  .card h2 { font-size: 21px; }
  .child-head { flex-wrap: wrap; }
  .btn-label-hide { display: none; }
  .modal { padding: 22px; }
  .modal-actions .btn { flex: 1; }
  .sub-list { padding-left: 14px; padding-right: 12px; }
  .node-actions { width: 100%; justify-content: flex-end; }
  .card-actions .btn { flex: 1; }
  .toggle { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
