/* ============================================================
   Owner Portal — consistent with brand, distinct workspace UI
   ============================================================ */
:root {
  --paper: #ffffff;         /* white workspace (matches public site) */
  --paper-3: #ebebe7;       /* neutral thumb/placeholder fill (was cream) */
  --ink: #0d0d0d;
  --panel: #0b0b0b;         /* near-black auth panel (Reform dark section) */
  --panel-2: #161616;
  --line: rgba(255, 255, 255, 0.12);
  --line-dark: rgba(13,13,13,0.14);
  --op-ink: #f6f6f4;
  --op-muted: #a7a7a2;
  --accent: #3F8CFF;
  --danger: #73A6FF;
  --ok: #7fc79a;
  --serif: "EB Garamond", "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, Arial, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; }
/* The [hidden] attribute must always win over layout rules like
   `.op-auth { display: grid }` / `.op-app` children. Without this, the
   built-in `hidden` (a type-selector rule) is overridden by class selectors,
   so both the login and dashboard would render at the same time. */
[hidden] { display: none !important; }
body.op {
  margin: 0;
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button { font-family: inherit; }

/* ---------- Auth ---------- */
.op-auth {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  background: var(--panel); color: var(--op-ink);
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top));
}
.op-auth-card { width: 100%; max-width: 420px; }
.op-eyebrow { font-size: 12px; letter-spacing: 0.26em; color: var(--op-muted); margin: 0 0 30px; }
.op-auth-title { font-family: var(--serif); font-weight: 300; font-size: clamp(2.4rem, 8vw, 3.4rem); margin: 0 0 8px; }
.op-auth-sub { color: var(--op-muted); margin: 0 0 28px; font-size: 15px; }
.op-auth-note { color: var(--op-muted); font-size: 12px; line-height: 1.6; margin-top: 22px; }
.op-back { display: inline-block; margin-top: 20px; color: var(--op-muted); font-size: 13px; }
.op-back:hover { color: var(--op-ink); }
.op-auth .op-field label { color: var(--op-muted); }
.op-auth .op-field input {
  background: transparent; color: var(--op-ink);
  border: 1px solid var(--line); border-radius: 10px;
}
.op-auth .op-field input:focus { border-color: var(--op-ink); outline: none; }
.op-auth-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 12px 0 0; }

/* ---------- Fields ---------- */
.op-field { display: grid; gap: 6px; margin-bottom: 16px; }
.op-field label, .op-plugins legend {
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink); opacity: 0.7; font-weight: 500;
}
.op-field input, .op-field textarea {
  font-family: var(--sans); font-size: 16px; /* 16px avoids iOS zoom */
  padding: 12px 14px; min-height: 46px;
  border: 1px solid var(--line-dark); border-radius: 10px;
  background: #fff; color: var(--ink); width: 100%;
}
.op-field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.op-hint { font-size: 12px; color: #8a887c; }

/* ---------- Buttons ---------- */
.op-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 500; letter-spacing: 0.02em;
  padding: 12px 20px; min-height: 46px;
  border: 1px solid var(--ink); border-radius: 999px;
  background: #fff; color: var(--ink); cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.op-btn:hover { background: var(--ink); color: var(--paper); }
.op-btn-primary { background: var(--ink); color: var(--paper); }
.op-btn-primary:hover { opacity: 0.85; background: var(--ink); color: var(--paper); }
.op-btn-ghost { background: transparent; }
.op-btn-sm { padding: 9px 16px; min-height: 40px; font-size: 13px; }
.op-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.op-auth .op-btn-primary { width: 100%; background: var(--op-ink); color: var(--panel); border-color: var(--op-ink); }

.op-icon {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line-dark); background: #fff; cursor: pointer; font-size: 15px;
}

/* ---------- App shell ---------- */
.op-app { min-height: 100dvh; padding-bottom: 120px; }
.op-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  padding-top: max(14px, env(safe-area-inset-top));
  background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-dark);
}
.op-header-l { display: flex; align-items: center; gap: 14px; }
.op-brand { font-weight: 600; letter-spacing: 0.2em; font-size: 14px; }
.op-badge {
  font-size: 11px; letter-spacing: 0.04em; color: #6f6d61;
  border: 1px solid var(--line-dark); border-radius: 999px; padding: 4px 10px;
}
.op-badge.local { color: #29539B; border-color: #89A6D9; background: #E3ECFB; }
.op-header-r { display: flex; gap: 8px; }
.op-linkbtn {
  font-size: 13px; color: var(--ink); background: transparent;
  border: 1px solid var(--line-dark); border-radius: 999px; padding: 8px 14px; cursor: pointer;
  min-height: 40px; display: inline-flex; align-items: center;
}
.op-linkbtn:hover { background: var(--ink); color: var(--paper); }

.op-toolbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: clamp(24px, 5vw, 48px) clamp(16px, 4vw, 40px) 16px;
  max-width: 1100px; margin: 0 auto; width: 100%;
}
.op-h2 { font-family: var(--serif); font-weight: 300; font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 0; }
.op-h3 { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; margin: 0; }
.op-muted { color: #6f6d61; font-size: 13px; margin: 4px 0 0; }
.op-empty { text-align: center; color: #6f6d61; padding: 60px 20px; max-width: 1100px; margin: 0 auto; }

/* ---------- Project list ---------- */
.op-list { list-style: none; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); max-width: 1100px; }
.op-item {
  display: grid;
  grid-template-columns: auto 64px 1fr auto;
  align-items: center; gap: 14px;
  padding: 14px; margin-bottom: 12px;
  border: 1px solid var(--line-dark); border-radius: 14px; background: #fff;
  transition: box-shadow 0.2s var(--ease), transform 0.12s var(--ease), opacity 0.2s;
  touch-action: manipulation;
}
.op-item.dragging { opacity: 0.6; box-shadow: 0 12px 30px rgba(0,0,0,0.14); }
.op-item.drag-over { border-color: var(--ink); }
.op-item.hidden-proj { opacity: 0.55; }
.op-handle {
  cursor: grab; touch-action: none; width: 34px; height: 44px;
  display: grid; place-items: center; color: #b3b1a3; font-size: 18px;
  border-radius: 8px; user-select: none;
}
.op-handle:active { cursor: grabbing; }
.op-item-thumb {
  width: 64px; height: 48px; border-radius: 8px; overflow: hidden;
  background: var(--paper-3); display: grid; place-items: center; color: #b3b1a3; font-size: 11px;
}
.op-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.op-item-main { min-width: 0; }
.op-item-title { font-family: var(--serif); font-size: 1.3rem; margin: 0; line-height: 1.1; }
.op-item-meta { font-size: 12px; color: #6f6d61; margin: 4px 0 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-item-actions { display: flex; gap: 6px; align-items: center; }
.op-pill {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line-dark); color: #6f6d61;
}
.op-pill.on { color: #2a6a3a; border-color: #a9d6bb; background: #eef7f1; }
.op-pill.off { color: #29539B; border-color: #89A6D9; background: #E3ECFB; }

@media (max-width: 640px) {
  .op-item { grid-template-columns: auto 48px 1fr; grid-template-rows: auto auto; }
  .op-item-thumb { width: 48px; height: 40px; }
  .op-item-actions { grid-column: 1 / -1; justify-content: flex-end; flex-wrap: wrap; }
}

/* ---------- Editor drawer ---------- */
.op-drawer { position: fixed; inset: 0; z-index: 40; }
.op-drawer-scrim { position: absolute; inset: 0; background: rgba(12,11,9,0.5); }
.op-drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(560px, 100%); background: var(--paper);
  padding: 20px clamp(16px, 4vw, 28px);
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  box-shadow: -20px 0 60px rgba(0,0,0,0.18);
  animation: drawerIn 0.35s var(--ease);
}
@keyframes drawerIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.op-drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.op-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.op-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .op-grid2, .op-grid3 { grid-template-columns: 1fr; } }

.op-media-row { display: flex; gap: 14px; align-items: center; }
.op-thumb {
  width: 120px; height: 90px; border-radius: 10px; overflow: hidden;
  background: var(--paper-3); display: grid; place-items: center; color: #b3b1a3; font-size: 12px;
  flex-shrink: 0; border: 1px solid var(--line-dark);
}
.op-thumb img { width: 100%; height: 100%; object-fit: cover; }
.op-media-actions { display: grid; gap: 8px; }

.op-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; margin-bottom: 10px; }
.op-gallery-item { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--paper-3); }
.op-gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.op-gallery-del {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  border: none; background: rgba(10,10,10,0.7); color: #fff; cursor: pointer; font-size: 12px;
}

.op-plugins { border: 1px solid var(--line-dark); border-radius: 12px; padding: 14px; }
.op-plugins legend { padding: 0 6px; }
.op-check { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 7px 0; cursor: pointer; text-transform: none; letter-spacing: 0; }
.op-check input { width: 18px; height: 18px; }
.op-visible { margin: 6px 0 12px; font-weight: 500; }

.op-drawer-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }

/* ---------- Publish bar ---------- */
.op-publishbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(16px, 4vw, 40px);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line-dark);
}
.op-publish-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #6f6d61; }
.op-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; }
.op-publish-actions { display: flex; gap: 8px; }
@media (max-width: 520px) {
  .op-publish-status span:not(.op-dot) { display: none; }
  .op-publishbar { gap: 8px; }
  .op-publish-actions { flex: 1; }
  .op-publish-actions .op-btn { flex: 1; }
}

/* ---------- Toast ---------- */
.op-toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: 999px;
  font-size: 14px; z-index: 60; opacity: 0; transition: opacity 0.25s, transform 0.25s;
  max-width: 90vw; text-align: center;
}
.op-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.op-toast.bad { background: #163B7C; }
.op-toast.ok { background: #234c33; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.01ms !important; }
}
