:root {
  --noir: #000; --bronze: #ac9277; --laiton: #d9c4a3; --papier: #f0f0f0; --blanc: #fff;
  --graphite: #2c2a28; --gris: #77736d; --ligne: #dcd9d4; --danger: #b3402c; --ok: #3f7a4a;
  --serif: "Bodoni Moda", Georgia, serif; --sans: "Instrument Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); background: var(--papier); color: var(--noir); font-size: 15px; line-height: 1.5; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--bronze); outline-offset: 2px; }
.muted { color: var(--gris); }
[hidden] { display: none !important; }

.logo { width: 180px; height: auto; overflow: visible; }
.logo text { fill: currentColor; }
.logo-h { font-family: var(--serif); font-style: italic; font-size: 78px; }
.logo-o { fill: none; stroke: var(--bronze); stroke-width: 3.2; }
.logo-orch { font-family: var(--sans); font-size: 17px; letter-spacing: 6.3px; fill: #8b8782 !important; }
.logo-harm { font-family: var(--sans); font-weight: 500; font-size: 22px; }
.logo-d { font-size: 15px; }
.logo-ol { font-weight: 600; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 999px; padding: .65em 1.2em; font-weight: 600; cursor: pointer; text-decoration: none; background: var(--blanc); border-color: var(--ligne); }
.btn:hover { border-color: var(--noir); }
.btn.primary { background: var(--noir); color: var(--papier); border-color: var(--noir); }
.btn.primary:hover { background: var(--graphite); }
.btn.bronze { background: var(--bronze); border-color: var(--bronze); }
.btn.ghost { background: transparent; border-color: rgba(240,240,240,.3); color: var(--papier); }
.btn.ghost:hover { border-color: var(--laiton); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: .4em .9em; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: wait; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: var(--gris); text-align: left; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--noir); }
.auth-card { width: 100%; max-width: 420px; background: var(--papier); border-radius: 8px; padding: 36px; }
.auth-card .logo { margin-bottom: 26px; }
.auth h1 { font-family: var(--serif); font-weight: 500; font-size: 1.7rem; margin: 0 0 6px; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: .85rem; }
input, textarea, select { width: 100%; border: 1px solid var(--ligne); border-radius: 6px; padding: .6em .75em; background: var(--blanc); font-weight: 400; font-size: .95rem; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--bronze); box-shadow: 0 0 0 3px rgba(172,146,119,.25); }
textarea { resize: vertical; min-height: 90px; }
textarea.long { min-height: 220px; }
.msg { min-height: 1.4em; margin: 14px 0 0; font-size: .9rem; }
.msg.err { color: var(--danger); } .msg.ok { color: var(--ok); }
.back { display: inline-block; margin-top: 18px; color: var(--gris); font-size: .9rem; }

/* Application */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--noir); color: var(--papier); padding: 26px 18px; display: flex; flex-direction: column; gap: 26px; position: sticky; top: 0; height: 100vh; }
.side-logo { color: var(--papier); display: block; padding: 0 8px; }
.side-nav { display: grid; gap: 2px; }
.side-nav button { text-align: left; background: none; border: 0; color: rgba(240,240,240,.75); padding: .65em .9em; border-radius: 6px; cursor: pointer; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.side-nav button:hover { background: rgba(240,240,240,.07); color: var(--papier); }
.side-nav button.active { background: var(--bronze); color: var(--noir); }
.badge { background: var(--laiton); color: var(--noir); border-radius: 999px; font-size: .75rem; padding: 0 .55em; font-weight: 700; }
.side-foot { margin-top: auto; display: grid; gap: 8px; }
.who { font-size: .8rem; color: #8b8782; margin: 0; word-break: break-all; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 16px; gap: 14px; }
  .side-nav { grid-auto-flow: column; overflow-x: auto; }
  .side-nav button { white-space: nowrap; }
  .side-foot { grid-auto-flow: column; justify-content: start; align-items: center; }
}

.main { padding: clamp(20px, 4vw, 48px); max-width: 1100px; width: 100%; }
.view-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.view-head h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(1.8rem, 3vw, 2.4rem); margin: 0; }
.view-head p { margin: 4px 0 0; color: var(--gris); }
.card { background: var(--blanc); border: 1px solid var(--ligne); border-radius: 8px; padding: 22px; margin-bottom: 18px; }
.card h2 { font-family: var(--serif); font-weight: 500; font-size: 1.35rem; margin: 0 0 14px; }
details.card > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.card > summary h2 { margin: 0; }
details.card > summary::after { content: "+"; font-size: 1.4rem; color: var(--bronze); }
details.card[open] > summary::after { content: "−"; }
details.card[open] > summary { margin-bottom: 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }
.hint { font-weight: 400; color: var(--gris); font-size: .8rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

.imgfield { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: start; }
.imgfield .pv { width: 120px; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; background: var(--papier); border: 1px solid var(--ligne); }
.imgfield .row { display: flex; gap: 8px; }
.imglist { display: flex; flex-wrap: wrap; gap: 8px; }
.imglist .it { position: relative; width: 110px; }
.imglist img { width: 110px; height: 82px; object-fit: cover; border-radius: 6px; }
.imglist .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.75); color: #fff; cursor: pointer; line-height: 1; }
.imglist .mv { position: absolute; bottom: 4px; left: 4px; display: flex; gap: 2px; }
.imglist .mv button { width: 22px; height: 22px; border: 0; border-radius: 4px; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: .75rem; }
.rowlist { display: grid; gap: 8px; }
.rowlist .r { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; }
.rowlist .r button { border: 0; background: none; color: var(--danger); cursor: pointer; font-size: 1.2rem; }

.table { width: 100%; border-collapse: collapse; }
.table td, .table th { padding: 12px 10px; border-bottom: 1px solid var(--ligne); text-align: left; vertical-align: middle; }
.table th { font-size: .8rem; color: var(--gris); font-weight: 600; }
.table img { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; }
.table tr.off td { opacity: .5; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--papier); }
.pill.on { background: #e3efe5; color: var(--ok); }
.pill.past { background: #eee; color: var(--gris); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.alb { background: var(--blanc); border: 1px solid var(--ligne); border-radius: 8px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; }
.alb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--papier); }
.alb div { padding: 10px 12px; }
.alb strong { display: block; font-size: .95rem; }
.alb span { color: var(--gris); font-size: .8rem; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.th { background: var(--blanc); border: 1px solid var(--ligne); border-radius: 8px; overflow: hidden; }
.th img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.th.off img { opacity: .35; }
.th .b { padding: 8px; display: grid; gap: 6px; }
.th input { font-size: .8rem; padding: .35em .5em; }
.th .row-actions { justify-content: space-between; }
.seg { display: inline-flex; background: var(--blanc); border: 1px solid var(--ligne); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: .45em 1em; border-radius: 999px; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--noir); color: var(--papier); }
.drop { border: 2px dashed var(--ligne); border-radius: 8px; padding: 22px; text-align: center; color: var(--gris); }
.drop.over { border-color: var(--bronze); background: rgba(172,146,119,.08); }
.progress { height: 4px; background: var(--ligne); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; background: var(--bronze); width: 0; transition: width .2s; }

.msgs { display: grid; gap: 12px; }
.m { background: var(--blanc); border: 1px solid var(--ligne); border-left: 4px solid var(--bronze); border-radius: 8px; padding: 16px 18px; }
.m.read { border-left-color: var(--ligne); }
.m header { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.m header strong { font-size: 1rem; }
.m time { color: var(--gris); font-size: .85rem; }
.m .subj { font-weight: 600; color: var(--bronze); margin: 4px 0 8px; }
.m p { white-space: pre-wrap; margin: 0; }
.empty { text-align: center; color: var(--gris); padding: 40px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal .card { width: 100%; max-width: 720px; max-height: 90vh; overflow: auto; margin: 0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 120px); background: var(--noir); color: var(--papier); padding: 12px 20px; border-radius: 999px; transition: transform .35s cubic-bezier(.2,.7,.1,1); z-index: 100; font-weight: 500; }
.toast.show { transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }
