/* Wedding Well — iPad-first styles
   Designed for: portrait + landscape iPad, 11" and 13", with and without Pencil.
   - 44pt minimum tap target (Apple HIG)
   - safe-area insets respected
   - dark mode by default on iPad in low light
   - system font fallback
   - pointer events only; no hover-only UI
*/

:root {
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --teal-50: #f0fdfa;
  --ink: #172a35;
  --ink-muted: #64747c;
  --line: #dbe4e3;
  --workspace: #edf1f1;
  --bg: #fff;
  --toolbar: #fff;
  --shadow: 0 8px 30px rgba(23, 42, 53, .14);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8eeee;
    --ink-muted: #94a3a8;
    --line: #2a3a40;
    --workspace: #0c1719;
    --bg: #152023;
    --toolbar: #152023;
    --teal-50: #0f2a2a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--workspace); color: var(--ink); font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif; overscroll-behavior: none; }

/* === Auth === */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card { background: var(--bg); border-radius: var(--radius); padding: 32px; max-width: 360px; width: 100%; box-shadow: var(--shadow); }
.brand { font: 700 28px/1 'DM Sans', Georgia, serif; color: var(--teal); margin: 0 0 8px; }
.tagline { color: var(--ink-muted); margin: 0 0 20px; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-muted); }
.form input { font-size: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); min-height: 44px; }
.form input:focus { outline: 3px solid rgba(15, 118, 110, .25); outline-offset: 2px; border-color: var(--teal); }
.form .primary, .form .link { font-size: 16px; padding: 12px 16px; border-radius: 10px; min-height: 44px; }
.form .link { background: none; border: 0; color: var(--teal); }

/* === Buttons === */
.primary { background: var(--teal); color: #fff; border: 0; padding: 12px 20px; border-radius: 10px; font: 600 16px 'DM Sans', sans-serif; min-height: 44px; }
.primary:hover { background: var(--teal-dark); }
.primary.small { padding: 8px 14px; font-size: 14px; min-height: 36px; border-radius: 8px; }
.icon-btn { background: transparent; border: 0; color: var(--ink); width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--teal-50); }
.icon-btn:disabled { opacity: .35; }
.icon-btn.small { width: 32px; height: 32px; }
.link { background: none; border: 0; color: var(--teal); font: 600 14px 'DM Sans', sans-serif; padding: 8px 12px; cursor: pointer; }
.error { color: #b91c1c; font-size: 14px; margin: 12px 0 0; }
.muted { color: var(--ink-muted); font-size: 13px; }

/* === Top bar === */
.topbar { position: fixed; top: var(--safe-top); left: 0; right: 0; height: 60px; padding: 0 12px; background: var(--toolbar); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; z-index: 10; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 4px; }
.title-block { display: flex; flex-direction: column; line-height: 1.1; padding-left: 4px; }
.title-input { background: none; border: 0; font: 600 18px 'DM Sans', sans-serif; color: var(--ink); padding: 4px 8px; border-radius: 6px; min-width: 200px; }
.title-input:focus { outline: 2px solid var(--teal); background: var(--teal-50); }
.save-state { font-size: 11px; color: var(--ink-muted); padding-left: 8px; }
.save-state.is-dirty { color: #b45309; }

/* === Editor === */
.app { display: grid; grid-template-rows: calc(60px + var(--safe-top)) 1fr calc(72px + var(--safe-bottom)); height: 100vh; }
.workspace { position: relative; overflow: hidden; background: var(--workspace); touch-action: none; }
#canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.pencil-cursor { position: absolute; pointer-events: none; border: 2px solid var(--teal); border-radius: 50%; transform: translate(-50%, -50%); transition: width .05s, height .05s, opacity .05s; z-index: 5; }
.pencil-cursor[hidden] { display: none; }

/* === Tool palette (bottom, thumb-reachable) === */
.palette { position: fixed; bottom: var(--safe-bottom); left: 0; right: 0; height: 72px; padding: 8px 12px; background: var(--toolbar); border-top: 1px solid var(--line); display: flex; gap: 6px; justify-content: space-around; align-items: center; z-index: 10; }
.tool-btn { background: transparent; border: 0; color: var(--ink-muted); width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; }
.tool-btn:hover { background: var(--teal-50); color: var(--ink); }
.tool-btn.is-active { background: var(--teal); color: #fff; }

/* === Inspector (right slide-over) === */
.inspector { position: fixed; top: calc(60px + var(--safe-top)); right: 0; bottom: calc(72px + var(--safe-bottom)); width: 320px; max-width: 90vw; background: var(--toolbar); border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; z-index: 8; box-shadow: var(--shadow); }
.inspector[hidden] { display: none; }
.inspector label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-muted); margin-bottom: 10px; }
.inspector input, .inspector select { font-size: 15px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }

/* === Dialogs === */
.dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: 420px; width: 90vw; background: var(--bg); color: var(--ink); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dialog h2 { font: 700 20px 'DM Sans', serif; margin: 0 0 8px; }
.share-row { display: flex; gap: 8px; margin: 16px 0; }
.share-row input { flex: 1; font-size: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }

/* === Projects list === */
.projects { min-height: 100vh; padding: calc(60px + var(--safe-top)) 0 calc(40px + var(--safe-bottom)); }
.project-list { list-style: none; margin: 0; padding: 16px 24px; display: grid; gap: 12px; }
.project-card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; min-height: 64px; }
.project-card:hover { border-color: var(--teal); }
.project-card h3 { margin: 0; font-size: 17px; }
.project-card p { margin: 4px 0 0; color: var(--ink-muted); font-size: 13px; }

/* === Responsive: phone (in case) === */
@media (max-width: 600px) {
  .topbar { height: 52px; }
  .app { grid-template-rows: calc(52px + var(--safe-top)) 1fr calc(64px + var(--safe-bottom)); }
  .inspector { top: calc(52px + var(--safe-top)); bottom: calc(64px + var(--safe-bottom)); width: 100vw; }
  .palette { height: 64px; }
  .tool-btn { width: 48px; height: 48px; }
  .title-input { min-width: 120px; font-size: 16px; }
}

/* === Landscape iPad: palette becomes a left rail === */
@media (min-width: 1024px) and (orientation: landscape) {
  .palette { position: fixed; top: calc(60px + var(--safe-top)); bottom: var(--safe-bottom); left: 0; right: auto; width: 72px; height: auto; padding: 12px 8px; flex-direction: column; gap: 6px; justify-content: flex-start; border-top: 0; border-right: 1px solid var(--line); }
  .app { grid-template-columns: 72px 1fr; grid-template-rows: calc(60px + var(--safe-top)) 1fr; }
  .app > .topbar { grid-column: 1 / -1; }
  .app > .workspace { grid-column: 2; }
  .app > .inspector { /* stays on right */ }
  .tool-btn { width: 56px; height: 56px; }
}
