:root {
    --paper: #fffaf8;
    --surface: #ffffff;
    --blush: #f4e1e4;
    --rose: #bd7889;
    --sage: #b9c8b3;
    --mist: #e8efec;
    --ink: #322b2b;
    --muted: #756a6c;
    --line: #eadfe0;
    --danger: #a74456;
    --shadow: 0 22px 60px rgba(79, 53, 60, .11);
}

* { box-sizing: border-box; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: "Plus Jakarta Sans", sans-serif;
    margin: 0;
    min-height: 100vh;
}

button, input, textarea, select { font: inherit; }

button, summary, label[for] { -webkit-tap-highlight-color: transparent; }

.login-page {
    align-items: center;
    background: linear-gradient(135deg, rgba(244,225,228,.85), transparent 48%), var(--paper);
    display: flex;
    isolation: isolate;
    justify-content: center;
    padding: 30px;
    position: relative;
}

.login-page::before,
.admin-page::before {
    background: url("../flower-silhouette.svg") left bottom / contain no-repeat;
    bottom: 0;
    content: "";
    height: min(82vh, 850px);
    left: 0;
    opacity: .2;
    pointer-events: none;
    position: fixed;
    width: min(52vw, 700px);
    z-index: -1;
}

.admin-page { isolation: isolate; }
.admin-page::before { left: auto; opacity: .12; right: -120px; transform: scaleX(-1); width: min(38vw, 520px); }

.login-card {
    background: rgba(255,255,255,.9);
    border: 1px solid rgba(255,255,255,.75);
    border-radius: 28px;
    box-shadow: var(--shadow);
    max-width: 470px;
    padding: 38px 42px 34px;
    width: 100%;
}

.login-brand {
    align-items: center;
    color: var(--ink);
    display: inline-flex;
    font-family: "Passions Conflict", cursive;
    font-size: 2.35rem;
    line-height: 1;
    text-decoration: none;
}

.login-brand img { height: 50px; margin-right: 12px; object-fit: contain; width: 28px; }
.login-copy { margin: 35px 0 25px; }
.eyebrow { color: var(--rose); font-size: .65rem; font-weight: 700; letter-spacing: .18em; margin: 0 0 8px; text-transform: uppercase; }
.login-copy h1 { font-family: "Passions Conflict", cursive; font-size: 3.65rem; font-weight: 400; line-height: .85; margin: 0 0 16px; }
.login-copy > p:last-child { color: var(--muted); font-size: .83rem; line-height: 1.7; margin: 0; }

.login-form { display: grid; gap: 17px; }
.login-form label, .field { display: grid; gap: 7px; }
.login-form label > span, .field > span { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.field > span small { color: #aa9ea0; font-size: .6rem; font-weight: 500; letter-spacing: 0; margin-left: 4px; text-transform: none; }

input, textarea, select {
    background: var(--surface);
    border: 1px solid #dfd4d6;
    border-radius: 11px;
    color: var(--ink);
    outline: none;
    padding: 12px 13px;
    transition: border-color .2s, box-shadow .2s;
    width: 100%;
}

textarea { line-height: 1.55; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(189,120,137,.12); }

.primary-button {
    background: var(--ink);
    border: 0;
    border-radius: 99px;
    color: white;
    cursor: pointer;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .1em;
    margin-top: 4px;
    padding: 14px 21px;
    text-transform: uppercase;
    transition: background .2s, transform .2s;
}

.primary-button:hover { background: var(--rose); transform: translateY(-1px); }
.primary-button:focus-visible, .outline-button:focus-visible, .text-button:focus-visible, summary:focus-visible, .move-button:focus-visible, .drag-handle:focus-visible, .delete-button:focus-visible, .user-menu-action:focus-visible, .dialog-close:focus-visible { outline: 2px solid var(--rose); outline-offset: 3px; }
.small-button { padding: 11px 16px; width: 100%; }
.back-link { color: var(--muted); display: inline-block; font-size: .7rem; margin-top: 25px; text-decoration: none; }
.back-link:hover { color: var(--rose); }

.notice { border-radius: 12px; font-size: .75rem; line-height: 1.55; margin: 0 0 20px; padding: 12px 14px; }
.notice-error { background: #f9e5e8; color: #813747; }
.notice-success { background: #e9f1e6; color: #496443; }

.admin-header {
    align-items: center;
    background: rgba(255,250,248,.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    padding: 14px clamp(20px, 4vw, 60px);
    position: sticky;
    top: 0;
    z-index: 30;
}

.admin-brand {
    align-items: center;
    color: var(--ink);
    display: flex;
    font-family: "Passions Conflict", cursive;
    font-size: 2.2rem;
    line-height: 1;
    text-decoration: none;
}

.admin-brand img { height: 42px; margin-right: 10px; object-fit: contain; width: 24px; }
.admin-actions { align-items: center; display: flex; gap: 18px; }
.text-button { color: var(--muted); font-size: .68rem; font-weight: 600; letter-spacing: .05em; text-decoration: none; text-transform: uppercase; }
.text-button:hover { color: var(--rose); }
.outline-button { background: transparent; border: 1px solid #d4c6c8; border-radius: 99px; color: var(--ink); cursor: pointer; font-size: .66rem; font-weight: 700; letter-spacing: .08em; padding: 9px 15px; text-transform: uppercase; }
.outline-button:hover { background: var(--blush); border-color: var(--blush); }

.user-menu { position: relative; }
.user-menu > summary { align-items: center; background: var(--ink); border-radius: 50%; color: white; cursor: pointer; display: flex; height: 38px; justify-content: center; list-style: none; transition: background .2s, transform .2s; width: 38px; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover, .user-menu[open] > summary { background: var(--rose); transform: translateY(-1px); }
.user-menu > summary svg { fill: none; height: 19px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; width: 19px; }
.user-menu-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); min-width: 220px; padding: 9px; position: absolute; right: 0; top: calc(100% + 10px); z-index: 40; }
.user-menu-heading { border-bottom: 1px solid var(--line); display: grid; gap: 2px; margin: 0 4px 5px; padding: 8px 7px 11px; }
.user-menu-heading span { color: var(--muted); font-size: .56rem; letter-spacing: .08em; text-transform: uppercase; }
.user-menu-heading strong { font-size: .75rem; }
.user-menu-card form { margin: 0; }
.user-menu-action { align-items: center; background: transparent; border: 0; border-radius: 9px; color: var(--ink); cursor: pointer; display: flex; font-size: .67rem; font-weight: 600; gap: 10px; padding: 10px 9px; text-align: left; width: 100%; }
.user-menu-action:hover { background: var(--blush); }
.user-menu-action svg { fill: none; height: 17px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.55; width: 17px; }
.logout-action { color: var(--danger); }

.admin-main { margin: 0 auto; max-width: 1500px; padding: clamp(35px, 6vw, 78px) clamp(20px, 4vw, 60px) 90px; }
.dashboard-heading { align-items: flex-end; display: flex; gap: 40px; justify-content: space-between; margin-bottom: 34px; }
.dashboard-heading h1 { font-family: "Passions Conflict", cursive; font-size: clamp(3.7rem, 7vw, 6.6rem); font-weight: 400; line-height: .82; margin: 0 0 19px; }
.dashboard-heading > div:first-child > p:last-child { color: var(--muted); font-size: .83rem; line-height: 1.7; margin: 0; max-width: 630px; }
.stats { align-items: center; display: flex; flex: 0 0 auto; gap: 12px; }
.stats div { align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; min-width: 82px; padding: 14px 12px; }
.stats strong { font-size: 1.15rem; }
.stats span { color: var(--muted); font-size: .56rem; font-weight: 600; letter-spacing: .1em; margin-top: 2px; text-transform: uppercase; }

.dashboard-grid { align-items: start; display: grid; gap: 24px; grid-template-columns: minmax(290px, 380px) minmax(0, 1fr); }
.upload-panel, .library-panel { background: rgba(255,255,255,.88); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 14px 40px rgba(79,53,60,.06); }
.upload-panel { padding: 25px; position: sticky; top: 94px; }
.library-panel { min-width: 0; padding: 25px; }
.panel-heading { align-items: flex-start; display: flex; gap: 12px; margin-bottom: 22px; }
.panel-heading h2 { font-size: .96rem; margin: 1px 0 5px; }
.panel-heading p { color: var(--muted); font-size: .67rem; line-height: 1.5; margin: 0; }
.panel-number { background: var(--blush); border-radius: 99px; color: #875761; flex: 0 0 auto; font-size: .57rem; font-weight: 700; letter-spacing: .08em; padding: 6px 9px; text-transform: uppercase; }
.library-heading { align-items: center; justify-content: space-between; }
.library-heading > div { align-items: flex-start; display: flex; gap: 12px; }
.save-status { color: #72816d; flex: 0 0 auto; font-size: .6rem; font-weight: 600; }
.save-status.is-error { color: var(--danger); }
.library-tools { align-items: flex-end; display: flex; flex-direction: column; gap: 7px; }
.delete-samples-form { margin: 0; }
.sample-button { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: .56rem; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.sample-button:hover { color: var(--danger); }

.upload-form { display: grid; gap: 16px; }
.upload-dropzone {
    align-items: center;
    background: #fcf5f5;
    border: 1px dashed #d5b7bd;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    min-height: 180px;
    padding: 25px 15px;
    text-align: center;
    transition: background .2s, border-color .2s, transform .2s;
}

.upload-dropzone:hover, .upload-dropzone.is-dragging { background: var(--blush); border-color: var(--rose); transform: translateY(-2px); }
.upload-dropzone svg { fill: none; height: 27px; margin-bottom: 12px; stroke: var(--rose); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; width: 27px; }
.upload-dropzone strong { font-size: .76rem; }
.upload-dropzone span { color: var(--muted); font-size: .67rem; margin-top: 4px; }
.upload-dropzone small { color: #a09597; font-size: .55rem; line-height: 1.5; margin-top: 12px; max-width: 250px; }
.upload-dropzone input { height: 1px; opacity: 0; overflow: hidden; padding: 0; position: absolute; width: 1px; }

.field-help { color: var(--muted); font-size: .58rem; line-height: 1.45; }

.password-dialog { background: transparent; border: 0; color: var(--ink); max-height: none; max-width: none; padding: 20px; width: min(100%, 470px); }
.password-dialog::backdrop { background: rgba(49, 39, 42, .58); backdrop-filter: blur(8px); }
.password-dialog-card { background: var(--surface); border: 1px solid rgba(255,255,255,.8); border-radius: 24px; box-shadow: var(--shadow); padding: 32px; position: relative; }
.password-dialog h2 { font-family: "Passions Conflict", cursive; font-size: 3.8rem; font-weight: 400; line-height: .84; margin: 0 0 13px; }
.dialog-copy { color: var(--muted); font-size: .72rem; line-height: 1.6; margin: 0 0 22px; }
.password-form { display: grid; gap: 14px; }
.dialog-close { align-items: center; background: var(--mist); border: 0; border-radius: 50%; color: var(--ink); cursor: pointer; display: flex; height: 34px; justify-content: center; position: absolute; right: 17px; top: 17px; width: 34px; }
.dialog-close:hover { background: var(--blush); }
.dialog-close svg { fill: none; height: 17px; stroke: currentColor; stroke-linecap: round; stroke-width: 1.5; width: 17px; }

.media-list { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.media-row { align-items: center; background: var(--paper); border: 1px solid transparent; border-radius: 14px; display: grid; gap: 11px; grid-template-columns: 26px 28px 68px minmax(120px, 1fr) auto; min-height: 82px; padding: 7px 9px; position: relative; transition: border-color .2s, box-shadow .2s, opacity .2s; }
.media-row:hover { border-color: var(--line); box-shadow: 0 8px 24px rgba(79,53,60,.06); }
.media-row.is-dragging { border-color: var(--rose); opacity: .5; }
.drag-handle { background: transparent; border: 0; color: #aa9da0; cursor: grab; padding: 4px; }
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { fill: none; height: 21px; stroke: currentColor; stroke-linecap: round; stroke-width: 3.5; width: 21px; }
.position-number { color: #a59699; font-size: .62rem; font-variant-numeric: tabular-nums; }
.media-thumb { background: var(--blush); border-radius: 10px; height: 66px; overflow: hidden; position: relative; width: 68px; }
.media-thumb img, .media-thumb video { height: 100%; object-fit: cover; width: 100%; }
.media-thumb span { background: rgba(50,43,43,.75); bottom: 4px; color: white; font-size: .45rem; left: 4px; letter-spacing: .08em; padding: 3px 5px; position: absolute; text-transform: uppercase; }
.media-summary { min-width: 0; }
.media-summary strong { display: block; font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-summary > span { color: var(--rose); display: block; font-size: .52rem; font-weight: 700; letter-spacing: .08em; margin-top: 5px; text-transform: uppercase; }
.media-summary p { color: var(--muted); font-size: .61rem; margin: 7px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { align-items: center; display: flex; gap: 4px; }
.move-button { background: transparent; border: 0; border-radius: 7px; color: var(--muted); cursor: pointer; height: 29px; padding: 0; width: 27px; }
.move-button:hover:not(:disabled) { background: var(--blush); color: var(--ink); }
.move-button:disabled { cursor: default; opacity: .25; }

.edit-details { position: relative; }
.edit-details summary { border: 1px solid #d9cdcf; border-radius: 99px; cursor: pointer; font-size: .58rem; font-weight: 700; list-style: none; padding: 8px 11px; text-transform: uppercase; }
.edit-details summary::-webkit-details-marker { display: none; }
.edit-details[open] summary { background: var(--ink); border-color: var(--ink); color: white; }
.edit-popover { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 17px; position: absolute; right: 0; top: calc(100% + 9px); width: 300px; z-index: 15; }
.edit-popover form:first-child { display: grid; gap: 12px; }
.edit-popover input, .edit-popover textarea, .edit-popover select { font-size: .7rem; padding: 9px 10px; }
.edit-popover .field > span { font-size: .58rem; }
.delete-form { border-top: 1px solid var(--line); margin-top: 13px; padding-top: 12px; }
.delete-button { background: transparent; border: 0; color: var(--danger); cursor: pointer; font-size: .62rem; padding: 2px; text-decoration: underline; text-underline-offset: 3px; }
.admin-empty { align-items: center; display: flex; flex-direction: column; padding: 85px 20px; text-align: center; }
.admin-empty > span { color: var(--rose); font-size: 2rem; }
.admin-empty h3 { font-family: "Passions Conflict", cursive; font-size: 3.2rem; font-weight: 400; line-height: 1; margin: 10px 0 2px; }
.admin-empty p { color: var(--muted); font-size: .72rem; }

@media (max-width: 980px) {
    .dashboard-heading { align-items: flex-start; flex-direction: column; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .upload-panel { position: static; }
}

@media (max-width: 650px) {
    .login-page { padding: 15px; }
    .login-card { border-radius: 22px; padding: 30px 24px; }
    .admin-header { padding: 11px 15px; }
    .admin-brand { font-size: 1.85rem; }
    .admin-brand img { height: 35px; width: 20px; }
    .admin-actions { gap: 10px; }
    .text-button { display: none; }
    .admin-main { padding: 35px 12px 70px; }
    .dashboard-heading { gap: 24px; }
    .dashboard-heading h1 { font-size: 4.15rem; }
    .stats { width: 100%; }
    .stats div { flex: 1; min-width: 0; }
    .upload-panel, .library-panel { border-radius: 18px; padding: 17px; }
    .library-heading { align-items: flex-start; }
    .save-status { margin-top: 6px; }
    .library-tools { align-items: flex-end; }
    .media-row { gap: 8px; grid-template-columns: 22px 54px minmax(90px, 1fr) auto; }
    .position-number { display: none; }
    .media-thumb { height: 58px; width: 54px; }
    .media-summary p { display: none; }
    .move-button { display: none; }
    .edit-popover { position: fixed; right: 12px; top: 90px; width: calc(100vw - 24px); }
    .password-dialog { padding: 12px; }
    .password-dialog-card { border-radius: 20px; padding: 28px 20px 22px; }
    .password-dialog h2 { font-size: 3.25rem; padding-right: 28px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
