:root {
  --ink: #1b1c1d;
  --ink-soft: #4f5358;
  --paper: #ffffff;
  --wash: #f5f6f6;
  --line: #e4e7e9;
  --accent: #d71942;
  --accent-dark: #b90e33;
  --green: #18794e;
  --red: #b42318;
  --radius-sm: 16px;
  --radius-md: 24px;
  --shadow: 0 18px 60px rgba(20, 22, 24, .10);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-width: 320px; overflow-x: clip; color: var(--ink); background: var(--wash); font-family: Manrope, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body.modal-open { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
::selection { color: #fff; background: var(--accent); }
:focus-visible { outline: 3px solid rgba(215, 25, 66, .24); outline-offset: 2px; }

.eyebrow { margin: 0 0 9px; color: var(--accent); font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.muted, .subhead { color: var(--ink-soft); }
.subhead { max-width: 680px; margin: 10px 0 0; font-size: 14px; line-height: 1.55; }
.form-error { min-height: 18px; margin: 0; color: var(--red); font-size: 13px; }

.button { min-height: 46px; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; font-weight: 800; line-height: 1; transition: transform .2s ease, box-shadow .2s ease, background .2s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .58; cursor: wait; transform: none; }
[data-sync]:disabled { cursor: not-allowed; }
.button--accent, .button--primary { color: #fff; background: var(--accent); }
.button--accent:hover, .button--primary:hover { background: var(--accent-dark); box-shadow: 0 12px 28px rgba(215, 25, 66, .22); }
.button--dark { color: #fff; background: var(--ink); }
.button--quiet { border-color: var(--line); background: var(--paper); }
.danger { border-color: #f1c7cf; color: var(--accent-dark); background: #fff; }

.login { min-height: 100svh; padding: 24px; display: grid; place-items: center; background: linear-gradient(135deg, var(--ink) 0 47%, var(--accent) 47% 100%); }
.login-card { width: min(460px, 100%); border-radius: 28px; padding: clamp(30px, 6vw, 54px); background: var(--paper); box-shadow: 0 36px 100px rgba(0, 0, 0, .32); }
.login-card img { width: 154px; margin-bottom: 44px; }
.login-card h1 { margin: 0 0 14px; font-size: clamp(38px, 8vw, 54px); line-height: .98; letter-spacing: -.055em; }
.login-card > p:not(.eyebrow):not(.form-error) { margin: 0; color: var(--ink-soft); line-height: 1.65; }
.login-card label { margin: 30px 0 10px; display: grid; gap: 8px; font-size: 12px; font-weight: 800; }
.login-card input { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; background: var(--wash); }
.login-card .button { width: 100%; margin-top: 6px; }

.app { min-height: 100svh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 10; height: 100svh; padding: 24px 16px; display: flex; flex-direction: column; color: #fff; background: var(--ink); }
.brand { min-height: 96px; padding: 10px 12px 22px; display: grid; align-content: start; gap: 10px; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.brand img { width: 112px; filter: grayscale(1) brightness(0) invert(1); }
.brand span { color: rgba(255, 255, 255, .56); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.sidebar nav { margin-top: 28px; display: grid; gap: 8px; }
.nav-item { width: 100%; min-height: 58px; border: 0; border-radius: 16px; padding: 0 14px; display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 8px; color: rgba(255, 255, 255, .66); background: transparent; text-align: left; }
.nav-item span { font-size: 10px; font-weight: 800; }
.nav-item strong { font-size: 14px; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.nav-item.is-active { color: #fff; background: var(--accent); }
.sidebar-foot { margin-top: auto; display: grid; border-top: 1px solid rgba(255, 255, 255, .12); padding: 18px 8px 0; }
.sidebar-foot a, .sidebar-foot button { min-height: 38px; border: 0; padding: 0; color: rgba(255, 255, 255, .62); background: transparent; font-size: 12px; text-align: left; }
.sidebar-foot a:hover, .sidebar-foot button:hover { color: #fff; }

.main { min-width: 0; padding: clamp(24px, 4vw, 54px); }
.panel { display: none; }
.panel.is-active { display: block; }
.page-head { min-height: 116px; margin-bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.page-head h1 { margin: 0; font-size: clamp(40px, 5vw, 68px); line-height: .96; letter-spacing: -.06em; }
.head-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.head-actions select { min-height: 46px; max-width: 280px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 40px 0 14px; color: var(--ink); background: var(--paper); font-size: 14px; font-weight: 700; }
.account-button { width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); font-weight: 900; letter-spacing: 2px; }

.page-library-toolbar { margin-bottom: 18px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.page-library-toolbar label { flex: 1; display: grid; gap: 6px; }
.page-library-toolbar label span { font-size: 10px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.page-library-toolbar input { width: min(100%, 520px); min-height: 42px; border: 1px solid var(--line); border-radius: 12px; padding: 0 13px; background: var(--wash); }
.page-library-toolbar > strong { color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
.page-library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.page-card { min-height: 230px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); display: flex; flex-direction: column; background: var(--paper); transition: transform .2s ease, border .2s ease, box-shadow .2s ease; }
.page-card:hover { transform: translateY(-3px); border-color: #f0a9b8; box-shadow: var(--shadow); }
.page-card__accent { height: 7px; background: var(--accent); }
.page-card__body { flex: 1; padding: 24px; display: flex; flex-direction: column; }
.page-card__meta { margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.page-card h2 { margin: 0 0 9px; font-size: 28px; line-height: 1.05; letter-spacing: -.045em; }
.page-card p { margin: 0 0 22px; color: var(--ink-soft); font-size: 13px; line-height: 1.55; }
.page-card button { width: 100%; min-height: 44px; margin-top: auto; border: 0; border-radius: 14px; color: #fff; background: var(--ink); font-size: 13px; font-weight: 900; }
.page-card:hover button { background: var(--accent); }
.back-button { min-height: 34px; margin-bottom: 18px; border: 0; padding: 0; color: var(--ink-soft); background: transparent; font-size: 12px; font-weight: 800; }
.back-button:hover { color: var(--accent); }
.editor-status { margin: 10px 0 0; color: var(--ink-soft); font-size: 13px; }
.editor-status.is-pending { color: var(--accent-dark); font-weight: 800; }
.editor-status.is-live { color: var(--green); font-weight: 800; }
.editor-help { margin: -5px 0 14px; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px 20px; border-radius: 15px; color: var(--ink-soft); background: #fff0f3; font-size: 11px; }
.editor-help strong { color: var(--accent-dark); }
.editor-help span { position: relative; }
.editor-help span + span::before { content: "→"; position: absolute; left: -14px; color: var(--accent); }

.editor-layout { height: calc(100svh - 300px); min-height: 620px; display: grid; grid-template-columns: 246px minmax(400px, 1fr) 310px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper); box-shadow: var(--shadow); }
.field-panel, .inspector { overflow: auto; background: var(--paper); }
.field-panel { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); padding: 22px; }
.search { position: sticky; top: 0; z-index: 2; padding: 18px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .96); }
.search span { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.search input { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: var(--wash); }
.field-filters { padding: 10px 10px 4px; display: flex; flex-wrap: wrap; gap: 5px; }
.field-filters button { min-height: 30px; border: 1px solid var(--line); border-radius: 9px; padding: 0 8px; background: var(--paper); font-size: 9px; font-weight: 900; }
.field-filters button.is-active { border-color: var(--accent); color: #fff; background: var(--accent); }
.field-count { margin: 16px 18px 8px; color: var(--ink-soft); font-size: 11px; }
.field-list { padding: 0 9px 20px; display: grid; gap: 4px; }
.field-button { width: 100%; border: 0; border-radius: 12px; padding: 11px; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; background: transparent; text-align: left; }
.field-button:hover, .field-button.is-active { color: var(--accent-dark); background: #fff0f3; }
.field-button i { color: var(--accent); font-style: normal; font-size: 12px; font-weight: 900; }
.field-button span { overflow: hidden; font-size: 11px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.preview-shell { min-width: 0; display: grid; grid-template-rows: 42px 1fr; background: #dfe1e2; }
.preview-bar { padding: 0 15px; display: flex; align-items: center; gap: 7px; border-bottom: 1px solid #d2d5d7; background: #eef0f1; }
.preview-bar span { width: 9px; height: 9px; border-radius: 50%; background: #c6c9cc; }
.preview-bar span:first-child { background: var(--accent); }
.preview-bar strong { margin-left: 8px; color: #666b70; font-size: 11px; }
.preview-shell iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.empty-state { min-height: 100%; display: grid; place-content: center; text-align: center; color: var(--ink-soft); }
.empty-state span { width: 42px; height: 42px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--accent); font-size: 25px; }
.empty-state h2 { margin: 14px 0 8px; color: var(--ink); font-size: 24px; line-height: 1.05; letter-spacing: -.035em; }
.empty-state p { margin: 0; font-size: 12px; line-height: 1.6; }
.inspector-form { display: grid; gap: 16px; }
.inspector-form h2 { margin: 0; font-size: 26px; line-height: 1.05; letter-spacing: -.04em; }
.inspector-form .field-kind { color: var(--accent); font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.inspector-form label, .password-form label { display: grid; gap: 8px; color: var(--ink-soft); font-size: 11px; font-weight: 800; }
.inspector-form input, .inspector-form textarea, .password-form input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--ink); background: var(--wash); font-size: 13px; font-weight: 400; }
.inspector-form textarea { min-height: 190px; resize: vertical; line-height: 1.55; }
.image-preview { aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius-sm); background: var(--wash); }
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.inspector-actions { padding-top: 4px; display: flex; flex-wrap: wrap; gap: 8px; }
.inspector-actions .danger { margin-left: auto; }

.ig-connect { margin-bottom: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 8px 28px rgba(20, 22, 24, .05); }
.ig-connect__status { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 700; color: var(--ink); }
.ig-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ig-dot--on { background: #1f9d55; }
.ig-dot--off { background: #c3c8cc; }
.ig-dot--wait { background: #d79a19; }
.ig-link { margin-left: 4px; border: 0; padding: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; font-weight: 700; text-decoration: underline; cursor: pointer; }
.ig-connect__form { margin-top: 14px; }
.ig-connect__lead { margin: 0 0 12px; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.ig-connect__row { display: flex; flex-wrap: wrap; gap: 12px; }
.ig-connect__row label { flex: 1 1 200px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink); }
.ig-connect__row input { min-height: 42px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; font-size: 14px; background: var(--paper); }
.ig-connect__row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #fce1e7; }
.ig-connect__form button[type="submit"] { margin-top: 12px; }
.gallery-toolbar { position: sticky; top: 0; z-index: 3; margin-bottom: 20px; padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, .94); box-shadow: 0 8px 28px rgba(20, 22, 24, .06); backdrop-filter: blur(16px); }
.filter-group, .batch-actions { display: flex; align-items: center; gap: 7px; }
.filter-group button, .batch-actions button { min-height: 38px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; background: var(--paper); font-size: 12px; font-weight: 800; }
.filter-group button.is-active { border-color: var(--accent); color: #fff; background: var(--accent); }
.filter-group span { opacity: .7; }
.batch-actions label { margin-right: 5px; color: var(--ink-soft); font-size: 12px; }
.batch-actions input, .gallery-media input { accent-color: var(--accent); }
.gallery-admin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.gallery-admin-card { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); transition: border .2s ease, transform .2s ease; }
.gallery-admin-card:hover { transform: translateY(-2px); }
.gallery-admin-card.is-visible { border-color: var(--accent); }
.gallery-media { position: relative; aspect-ratio: 4 / 5; background: #e7e9ea; }
.gallery-media img { width: 100%; height: 100%; object-fit: cover; }
.gallery-media input { position: absolute; top: 12px; left: 12px; width: 21px; height: 21px; }
.gallery-badge { position: absolute; top: 11px; right: 11px; border-radius: 99px; padding: 6px 9px; color: #fff; background: rgba(27, 28, 29, .82); font-size: 9px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.gallery-badge.visible { background: var(--accent); }
.gallery-card-body { padding: 13px; }
.gallery-card-body textarea { width: 100%; min-height: 68px; border: 0; resize: vertical; color: var(--ink-soft); background: transparent; font-size: 11px; line-height: 1.5; }
.gallery-card-meta { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gallery-card-meta time { color: var(--ink-soft); font-size: 10px; }
.gallery-card-meta button { min-height: 34px; border: 0; border-radius: 11px; padding: 0 11px; color: #fff; background: var(--ink); font-size: 10px; font-weight: 900; }
.gallery-admin-card:not(.is-visible) .gallery-card-meta button { background: var(--accent); }
.gallery-empty { grid-column: 1 / -1; border: 1px dashed #c8cccf; border-radius: var(--radius-md); padding: 86px 24px; color: var(--ink-soft); text-align: center; }
.gallery-empty strong { display: block; margin-bottom: 8px; color: var(--ink); font-size: 22px; }

.account-modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 22px; }
.modal-backdrop { position: absolute; inset: 0; border: 0; background: rgba(15, 16, 17, .72); backdrop-filter: blur(8px); }
.modal-card { position: relative; width: min(500px, 100%); max-height: calc(100svh - 44px); overflow: auto; border-radius: 28px; padding: clamp(26px, 5vw, 44px); background: var(--paper); box-shadow: 0 30px 100px rgba(0, 0, 0, .28); }
.modal-card h2 { margin: 0 0 10px; font-size: 40px; line-height: 1; letter-spacing: -.055em; }
.modal-card > p:not(.eyebrow) { color: var(--ink-soft); }
.modal-close { position: absolute; top: 18px; right: 18px; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); font-size: 24px; }
.password-form { margin-top: 26px; display: grid; gap: 14px; }
.password-form input { min-height: 48px; }

.toast { position: fixed; z-index: 80; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 48px)); border-radius: 14px; padding: 14px 17px; color: #fff; background: var(--ink); box-shadow: 0 18px 50px rgba(0, 0, 0, .22); opacity: 0; transform: translateY(14px); pointer-events: none; transition: .2s ease; font-size: 13px; font-weight: 700; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--accent-dark); }

@media (max-width: 1180px) {
  .editor-layout { grid-template-columns: 210px minmax(360px, 1fr) 270px; }
  .page-library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery-admin-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 920px) {
  .app { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: 9px; }
  .brand { padding-inline: 3px; }
  .brand img { width: 58px; }
  .brand span, .nav-item strong, .sidebar-foot { display: none; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 0; }
  .main { padding: 26px 18px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .head-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .editor-layout { height: auto; grid-template-columns: 190px minmax(420px, 1fr); overflow: auto; }
  .preview-shell { height: 680px; }
  .inspector { grid-column: 1 / -1; min-height: 330px; border: 0; border-top: 1px solid var(--line); }
  .gallery-admin-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-toolbar { align-items: flex-start; flex-direction: column; }
  .editor-help span + span::before { content: none; }
}

@media (max-width: 640px) {
  .app { display: block; padding-bottom: 76px; }
  .sidebar { position: fixed; inset: auto 0 0; width: 100%; height: 68px; padding: 7px; }
  .brand, .sidebar-foot { display: none; }
  .sidebar nav { height: 100%; margin: 0; grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .nav-item { min-height: 54px; grid-template-columns: 24px auto; justify-content: center; justify-items: start; }
  .nav-item strong { display: block; font-size: 12px; }
  .main { padding: 22px 14px; }
  .page-head { min-height: 0; margin-bottom: 20px; }
  .page-head h1 { font-size: 44px; }
  .head-actions select { width: 100%; max-width: none; }
  .head-actions .button { flex: 1; }
  .editor-layout { display: block; min-height: 0; border-radius: 18px; }
  .page-library-toolbar { align-items: stretch; flex-direction: column; }
  .page-library-toolbar input { width: 100%; }
  .page-library-grid { grid-template-columns: 1fr; }
  .page-card { min-height: 210px; }
  .editor-actions .button { flex: 1 1 auto; }
  .editor-help { display: grid; }
  .field-panel { max-height: 280px; border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-shell { height: 600px; }
  .inspector { min-height: 300px; }
  .gallery-admin-grid { grid-template-columns: 1fr; }
  .filter-group { width: 100%; overflow-x: auto; padding-bottom: 3px; }
  .filter-group button { flex: none; }
  .batch-actions { align-items: stretch; flex-wrap: wrap; }
  .batch-actions label { width: 100%; }
  .toast { right: 14px; bottom: 84px; max-width: calc(100vw - 28px); }
}
