/* Studio admin (prototype) - builds on styles.css + portal.css */
.ad-wrap { padding: 40px 0 80px; }
.ad-banner { display: flex; gap: 12px; padding: 12px 16px; border: 1px dashed var(--line); border-radius: var(--radius); font-size: .9rem; line-height: 1.6; margin-bottom: 32px; }
.ad-banner > i { color: var(--muted); margin-top: 4px; }
.ad-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 28px; }
.ad-top h1, .ad-head h1 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); }
.ad-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ad-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--ink); color: var(--on-ink); border: 1px solid var(--ink); border-radius: 999px; padding: .6rem 1.15rem; font-family: var(--head); font-size: .88rem; cursor: pointer; transition: background .2s, color .2s, border-color .2s; white-space: nowrap; }
.ad-btn:hover { background: transparent; color: var(--ink); }
.ad-btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.ad-btn.ghost:hover { border-color: var(--ink); }
.ad-btn.small { padding: .4rem .85rem; font-size: .82rem; }
.ad-btn.danger { background: var(--surface); color: var(--bad-text); border-color: var(--line); }
.ad-btn.danger:hover { border-color: var(--bad); }
.ad-btn:disabled { opacity: .45; cursor: default; }

/* project list */
.ad-list { display: grid; gap: 12px; }
.ad-card { display: grid; grid-template-columns: 1fr 140px 150px auto; gap: 20px; align-items: center; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.ad-card h3 { font-size: 1.1rem; }
.ad-card p { font-size: .88rem; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.ad-card .ad-num { font-size: .82rem; color: var(--muted); display: grid; gap: 4px; }
.ad-card .ad-num b { font-family: var(--head); font-weight: 500; color: var(--ink); font-size: 1rem; }
.ad-card .ad-actions { justify-content: flex-end; }

/* editor */
.ad-bar { position: sticky; top: var(--nav-h); z-index: 30; background: var(--nav-bg); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); margin-top: -40px; margin-bottom: 32px; }
.ad-bar .container { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; }
.ad-bar .ad-actions { margin-left: auto; }
.ad-back { background: none; border: 0; color: var(--ink); font-family: var(--head); font-size: .9rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; padding: 6px 0; }
.ad-state { font-size: .85rem; color: var(--muted); }
.ad-state.dirty { color: var(--bad-text); }
.ad-tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--line); margin: 24px 0 28px; overflow-x: auto; scrollbar-width: none; }
.ad-tabs button { flex: none; background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 0; font-family: var(--head); font-size: .95rem; color: var(--muted); cursor: pointer; }
.ad-tabs button:hover, .ad-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.ad-panel h2 { font-size: 1.4rem; margin-bottom: 6px; }
.ad-hint { color: var(--muted); font-size: .9rem; margin-bottom: 18px; }
.ad-warn { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; color: var(--ink); background: var(--tint); border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; }
.ad-warn i { color: var(--bad); margin-top: 4px; }

.ad-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; max-width: 820px; }
.ad-form .full { grid-column: 1 / -1; }
.ad-btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 12px; }
.ad-btn-row .ad-add, .ad-btn-row .ad-hint { margin: 0; }
.ad-choice { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.ad-choice legend { font-family: var(--head); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; padding: 0; }
.ad-choice label { position: relative; cursor: pointer; }
.ad-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ad-choice span { display: inline-flex; align-items: center; gap: 10px; padding: .75rem 1.1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-family: var(--head); font-size: .92rem; transition: border-color .2s, background .2s, color .2s; }
.ad-choice span i { color: var(--muted); transition: color .2s; }
.ad-choice label:hover span { border-color: var(--ink); }
.ad-choice input:checked + span { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.ad-choice input:checked + span i { color: var(--on-ink); }
.ad-choice input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 3px; }
.ad-choice input:disabled + span { opacity: .45; cursor: not-allowed; }
.ad-choice label:has(input:disabled) { cursor: not-allowed; }
.ad-choice label:has(input:disabled):hover span { border-color: var(--line); }
.ad-form h3 { grid-column: 1 / -1; font-size: 1.05rem; margin-top: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.ad-inline { display: flex; gap: 8px; }
.ad-inline input { flex: 1; min-width: 0; }

/* editable tables */
.ad-table-wrap { overflow-x: auto; }
.ad-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ad-table th { text-align: left; font-family: var(--head); font-weight: 500; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ad-table td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ad-table th.n, .ad-table td.n { text-align: right; }
.ad-table td.calc { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; padding-right: 10px; }
.ad-table input, .ad-table select, .ad-in { width: 100%; min-width: 0; font: inherit; font-size: .9rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; outline: none; }
.ad-table input:focus, .ad-table select:focus, .ad-in:focus, .ad-form input:focus, .ad-form textarea:focus, .ad-form select:focus { border-color: var(--ink); }
.ad-table input[type="number"] { text-align: right; }
.ad-table input[type="date"] { min-width: 140px; }
.ad-table .w-name { min-width: 220px; }
.ad-table .w-num { width: 96px; }
.ad-table .w-pct { width: 76px; }
.ad-table .w-unit { width: 84px; }
.ad-row-btns { display: flex; gap: 2px; justify-content: flex-end; }
.ad-icon { width: 32px; height: 32px; border: 0; background: none; color: var(--muted); border-radius: 6px; cursor: pointer; }
.ad-icon:hover { color: var(--ink); background: var(--tint); }
.ad-icon.del:hover { color: var(--bad-text); }
.ad-icon:disabled { opacity: .3; cursor: default; background: none; }
.ad-add { margin-top: 12px; }
.ad-sum { display: flex; justify-content: flex-end; gap: 24px; padding: 12px 6px; font-family: var(--head); color: var(--ink); }
.ad-sum span { color: var(--muted); font-family: var(--body); }

.ad-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; background: var(--surface); }
.ad-group-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.ad-group-head .ad-in { font-family: var(--head); font-size: 1rem; font-weight: 500; max-width: 360px; }
.ad-group-head .ad-sub { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* site updates */
.ad-upd-form { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; background: var(--surface); margin-bottom: 28px; }
.ad-upd-form textarea { width: 100%; min-height: 96px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; outline: none; resize: vertical; }
.ad-form select, .ad-form textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; outline: none; }
.ad-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.ad-thumbs figure { position: relative; width: 110px; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--tint); }
.ad-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.ad-thumbs button { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: .75rem; }
.ad-file { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.ad-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ad-upd { display: grid; grid-template-columns: 120px 1fr auto; gap: 18px; padding: 18px 0; border-top: 1px solid var(--line); }
.ad-upd:last-child { border-bottom: 1px solid var(--line); }
.ad-upd .up-photos a { width: 120px; }

.ad-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; background: var(--ink); color: var(--on-ink); padding: 10px 18px; border-radius: 999px; font-size: .9rem; box-shadow: 0 12px 30px -12px rgba(0,0,0,.5); max-width: calc(100vw - 32px); }

@media (max-width: 760px) {
  .ad-card { grid-template-columns: 1fr 1fr; }
  .ad-card > div:first-child { grid-column: 1 / -1; }
  .ad-card .ad-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .ad-bar .container { flex-wrap: wrap; gap: 8px; }
  .ad-state { order: 3; width: 100%; }
  .ad-form { grid-template-columns: 1fr; }
  .ad-upd { grid-template-columns: 1fr; gap: 8px; }
  .ad-group-head { flex-wrap: wrap; }
  .ad-group-head .ad-sub { margin-left: 0; }
}

/* a server job (save, upload, login change) is running */
body.ad-busy { cursor: progress; }
body.ad-busy .ad-btn, body.ad-busy .pt-submit { pointer-events: none; opacity: .6; }

/* Drawings tab */
.ad-dw-up { grid-template-columns: 1.3fr .7fr 1fr 1.3fr; max-width: none; align-items: end; margin: 8px 0 24px; padding: 18px; border: 1px dashed var(--line); border-radius: var(--radius); }
.ad-dw-up .ad-file { justify-content: center; min-height: 44px; }
.ad-dw-file { font-size: .86rem; color: var(--ink); overflow-wrap: anywhere; min-width: 160px; }
.ad-dw-file small { display: block; color: var(--muted); }
@media (max-width: 1000px) { .ad-dw-up { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .ad-dw-up { grid-template-columns: 1fr; padding: 14px; } }
