*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ps-terracotta:       #A84B2A;
  --ps-terracotta-dark:  #8E3D20;
  --ps-terracotta-light: #EDD5CB;
  --ps-terracotta-faint: #F5EBE7;
  --ps-azul:             #788990;
  --ps-azul-dark:        #647880;
  --ps-azul-light:       #D0DADD;
  --ps-azul-faint:       #EBF0F2;
  --ps-verde:            #8D957E;
  --ps-verde-dark:       #717A64;
  --ps-verde-light:      #D4DAD0;
  --ps-verde-faint:      #EEF1EC;
  --ps-warm:             #B8936A;
  --ps-warm-light:       #EDE0D0;
  --ps-bege-rose:        #E3D6C5;
  --ps-off-white:        #EDEAE4;
  --ps-surface:          #F7F4F0;
  --ps-sidebar:          #1E2022;
  --ps-sidebar-2:        #252A2C;
  --ps-text-primary:     #1E2022;
  --ps-text-secondary:   #5C5852;
  --ps-text-muted:       #9C958D;
  --ps-border:           #DDD5C8;
  --ps-border-strong:    #C8BFB4;
  --ps-shadow:           0 2px 12px rgba(30,32,34,.07);
  --ps-shadow-lg:        0 8px 32px rgba(30,32,34,.12);
  --ps-radius:           14px;
  --ps-radius-sm:        9px;
  --ps-radius-xs:        6px;
  --ps-radius-pill:      100px;
  --header-h: 52px;
  --tagbar-w: 220px;
  --rail-w:   52px;
  --drawer-w: 280px;
  --mono:    'Red Hat Mono', monospace;
  --display: 'Red Hat Display', sans-serif;
}

html, body {
  height: 100%; overflow: hidden;
  font-family: var(--display);
  background: var(--ps-off-white);
  color: var(--ps-text-primary);
  font-size: 14px;
}

/* ── Header ── */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h); z-index: 100;
  background: var(--ps-sidebar); border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; padding: 0 20px; gap: 0;
}
.brand { display: flex; align-items: center; gap: 9px; margin-right: 28px; flex-shrink: 0; text-decoration: none; }
.brand-logo { width: 22px; height: 22px; object-fit: contain; flex-shrink: 0; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -.3px; color: white; }
.brand-name em { color: var(--ps-azul); font-style: normal; }
.header-nav { display: flex; align-items: center; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 5px; padding: 6px 13px; border-radius: var(--ps-radius-pill); font-size: 13px; font-weight: 500; cursor: pointer; color: rgba(255,255,255,.45); transition: all .15s; white-space: nowrap; user-select: none; }
.nav-item:hover { color: rgba(255,255,255,.8); background: rgba(255,255,255,.06); }
.nav-item.active { color: white; background: rgba(120,137,144,.25); }
.nav-item em { font-style: normal; color: var(--ps-azul); opacity: .8; }
.nav-item.active em { opacity: 1; }
.nav-sep { width: 1px; height: 18px; background: rgba(255,255,255,.1); margin: 0 8px; flex-shrink: 0; }
.header-spacer { flex: 1; }
.header-right { display: flex; align-items: center; gap: 8px; }
.hbtn { display: flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: var(--ps-radius-pill); font-family: var(--display); font-size: 12.5px; font-weight: 500; cursor: pointer; border: none; transition: all .15s; }
.hbtn-ghost { background: transparent; color: rgba(255,255,255,.45); border: 1px solid rgba(255,255,255,.12); }
.hbtn-ghost:hover { color: white; border-color: rgba(255,255,255,.25); }
.hbtn-primary { background: var(--ps-terracotta); color: white; }
.hbtn-primary:hover { background: var(--ps-terracotta-dark); }

/* ── App layout ── */
.app-body { position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0; overflow: hidden; }
.view { display: none; width: 100%; height: 100%; }
.view.active { display: flex; }

/* ── Breadcrumb bar (inside workspace, light-themed) ── */
.bc-bar { display: none; }
.bc-bar.bc-active {
  flex-shrink: 0; height: 34px;
  background: var(--ps-off-white);
  border-bottom: 1.5px solid var(--ps-border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 0;
}
.bc-chips {
  flex: 1; display: flex; align-items: center; gap: 5px;
  overflow-x: auto; min-width: 0; scrollbar-width: none;
}
.bc-chips::-webkit-scrollbar { display: none; }
.bc-chip {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--ps-surface); border: 1.5px solid var(--ps-border);
  border-radius: var(--ps-radius-sm); padding: 2px 5px 2px 7px;
  cursor: grab; white-space: nowrap; user-select: none; flex-shrink: 0;
  transition: background .12s, border-color .12s;
}
.bc-chip:hover { background: var(--ps-bege-rose); border-color: var(--ps-azul-light); }
.bc-chip.bc-dragging { opacity: .4; cursor: grabbing; }
.bc-chip.bc-over { border-color: var(--ps-azul); background: var(--ps-azul-faint, #EEF2F4); }
.bc-chip-label {
  font-family: var(--mono); font-size: 11px;
  color: var(--ps-azul-dark); transition: color .12s;
}
.bc-chip-x {
  background: none; border: none; cursor: pointer;
  color: var(--ps-text-muted); font-size: 13px; line-height: 1;
  padding: 0 0 0 3px; opacity: 0; transition: opacity .12s, color .12s;
}
.bc-chip:hover .bc-chip-x { opacity: .7; }
.bc-chip:hover .bc-chip-x:hover { opacity: 1; color: var(--ps-terracotta); }
.bc-divider { width: 1px; height: 16px; background: var(--ps-border); flex-shrink: 0; margin: 0 6px 0 8px; }
.bc-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.bc-btn {
  background: none; border: none; cursor: pointer;
  color: var(--ps-text-muted); font-family: var(--display); font-size: 11.5px;
  padding: 4px 8px; border-radius: var(--ps-radius-sm);
  display: flex; align-items: center; gap: 4px; transition: all .12s;
}
.bc-btn:hover:not(:disabled) { background: var(--ps-bege-rose); color: var(--ps-text-secondary); }
.bc-btn:disabled { opacity: .3; cursor: not-allowed; }
@keyframes bc-flash {
  0%, 100% { box-shadow: none; }
  35% { box-shadow: 0 0 0 2px var(--ps-azul-light); }
}
.bc-flash { animation: bc-flash .75s ease; }
@media (max-width: 700px) {
  .bc-bar.bc-active { height: 30px; padding: 0 10px; }
  .bc-chip { padding: 1px 4px 1px 6px; }
  .bc-chip-label { font-size: 10px; }
  .bc-btn { font-size: 10.5px; padding: 3px 5px; gap: 3px; }
}

/* ── Mobile bottom nav ── */
.mobile-nav { display: none; }

.mob-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; color: rgba(255,255,255,.35); font-size: 10px; font-weight: 600;
  letter-spacing: .03em; text-transform: uppercase; transition: color .15s;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mob-tab.active { color: var(--ps-azul); }
.mob-tab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 700px) {
  .header-nav, .header-spacer { display: none; }
  .header { padding: 0 16px; justify-content: center; }
  .brand { margin-right: 0; }
  .app-body { bottom: 56px; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 56px;
    background: var(--ps-sidebar); border-top: 1px solid rgba(255,255,255,.12); z-index: 100;
  }
}

/* ── Font size: Large ── */
html.font-large { zoom: 1.14; }

/* contrast vars are set dynamically via JS on the root element */

/* ── Rail: spacer + settings menu ── */
.rail-spacer { flex: 1; }
.rail-settings-wrap { position: relative; }
.rail-btn-share  { color: var(--ps-azul) !important; }
.rail-btn.rail-btn-submit, .rail-sep-submit { display: none; }
.ps-logged-in .rail-btn.rail-btn-submit { display: flex; }
.ps-logged-in .rail-sep-submit { display: block; }
.rail-settings-menu {
  display: none; position: absolute; bottom: calc(100% + 10px); right: 0;
  width: 192px; background: var(--ps-surface); border: 1.5px solid var(--ps-border);
  border-radius: var(--ps-radius); padding: 14px; box-shadow: var(--ps-shadow-lg); z-index: 300;
}
.rail-settings-menu.open { display: block; }
.rsm-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--ps-text-muted); margin-bottom: 8px; }
.rsm-seg { display: flex; gap: 4px; margin-bottom: 4px; }
.rsm-seg-btn { flex: 1; padding: 6px 4px; border: 1.5px solid var(--ps-border); border-radius: var(--ps-radius-xs); background: transparent; font-family: var(--display); font-size: 12px; font-weight: 500; color: var(--ps-text-secondary); cursor: pointer; transition: all .12s; }
.rsm-seg-btn:hover { border-color: var(--ps-azul-light); color: var(--ps-text-primary); }
.rsm-seg-btn.active { background: var(--ps-azul); border-color: var(--ps-azul); color: white; }
.rsm-divider { height: 1px; background: var(--ps-border); margin: 12px 0; }
.rsm-toggle-label { font-size: 12px; font-weight: 500; color: var(--ps-text-secondary); }
.rsm-slider-section { display: flex; flex-direction: column; gap: 8px; }
.rsm-slider-header { display: flex; align-items: center; justify-content: space-between; }
.rsm-slider-val { font-size: 11px; font-weight: 600; color: var(--ps-azul); font-family: var(--mono); }
.rsm-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  background: var(--ps-border); outline: none; cursor: pointer;
}
.rsm-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ps-azul); cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: background .12s;
}
.rsm-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; border: none;
  background: var(--ps-azul); cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.rsm-slider:hover::-webkit-slider-thumb { background: var(--ps-azul-dark); }

/* ── Welcome modal ── */
#welcome-overlay { position: fixed; inset: 0; background: rgba(30,32,34,.5); z-index: 9990; display: flex; align-items: center; justify-content: center; padding: 20px; }
#welcome-overlay.hidden { display: none; }
#welcome-box { background: var(--ps-surface); border: 1.5px solid var(--ps-border); border-radius: var(--ps-radius); padding: 32px 36px; width: 100%; max-width: 480px; box-shadow: 0 32px 80px rgba(30,32,34,.22); position: relative; }
#welcome-close { position: absolute; top: 14px; right: 16px; width: 28px; height: 28px; border-radius: 50%; background: var(--ps-bege-rose); border: none; cursor: pointer; font-size: 16px; color: var(--ps-text-muted); display: flex; align-items: center; justify-content: center; transition: all .12s; }
#welcome-close:hover { background: var(--ps-azul-light); color: var(--ps-azul-dark); }
.welcome-brand { font-size: 13px; font-weight: 700; color: var(--ps-text-muted); margin-bottom: 12px; letter-spacing: .02em; }
.welcome-brand em { font-style: normal; color: var(--ps-azul); }
.welcome-heading { font-size: 22px; font-weight: 700; color: var(--ps-text-primary); letter-spacing: -.4px; line-height: 1.25; margin-bottom: 12px; }
.welcome-sub { font-size: 13.5px; color: var(--ps-text-secondary); line-height: 1.65; margin-bottom: 24px; }
.welcome-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 28px; }
.welcome-step { display: flex; align-items: flex-start; gap: 12px; }
.ws-num { width: 22px; height: 22px; border-radius: 50%; background: var(--ps-azul-faint); border: 1.5px solid var(--ps-azul-light); color: var(--ps-azul-dark); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.ws-text { font-size: 13px; color: var(--ps-text-secondary); line-height: 1.55; }
.ws-text strong { color: var(--ps-text-primary); font-weight: 600; }
.welcome-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.welcome-skip { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ps-text-muted); cursor: pointer; user-select: none; }
.welcome-skip input { cursor: pointer; accent-color: var(--ps-azul); }
.welcome-cta { background: var(--ps-terracotta); color: white; border: none; border-radius: var(--ps-radius-pill); padding: 9px 22px; font-family: var(--display); font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s; white-space: nowrap; }
.welcome-cta:hover { background: var(--ps-terracotta-dark); }

/* ── Share popup ── */
#share-popup {
  position: fixed; bottom: 80px; right: 64px; width: 320px;
  background: var(--ps-surface); border: 1.5px solid var(--ps-border);
  border-radius: var(--ps-radius); padding: 16px; box-shadow: var(--ps-shadow-lg); z-index: 500;
}
#share-popup.hidden { display: none; }
.share-popup-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.share-popup-title { font-size: 13px; font-weight: 700; color: var(--ps-text-primary); }
.share-popup-close { width: 22px; height: 22px; border-radius: 50%; background: var(--ps-bege-rose); border: none; cursor: pointer; font-size: 14px; color: var(--ps-text-muted); display: flex; align-items: center; justify-content: center; transition: all .12s; }
.share-popup-close:hover { background: var(--ps-azul-light); color: var(--ps-azul-dark); }
.share-popup-desc { font-size: 12px; color: var(--ps-text-muted); margin-bottom: 12px; line-height: 1.5; }
.share-link-row { display: flex; gap: 6px; }
.share-link-input { flex: 1; border: 1.5px solid var(--ps-border); border-radius: var(--ps-radius-xs); padding: 7px 10px; font-family: var(--mono); font-size: 11px; color: var(--ps-text-secondary); background: var(--ps-off-white); outline: none; min-width: 0; }
.share-copy-btn { background: var(--ps-azul); color: white; border: none; border-radius: var(--ps-radius-xs); padding: 7px 14px; font-family: var(--display); font-size: 12px; font-weight: 600; cursor: pointer; transition: background .15s; white-space: nowrap; }
.share-copy-btn:hover { background: var(--ps-azul-dark); }
.share-popup-status { font-size: 12px; color: var(--ps-verde-dark); margin-top: 8px; min-height: 16px; }
