/* Storytelling AI - design system, v2.
   One smooth dark surface: charcoal black, white type, warm orange accent.
   No boxed panels, almost no borders - hierarchy comes from spacing,
   contrast and image density. English, LTR. */

:root{
  --bg:#0f0f10;
  --surface:#1b1b1d;
  --surface-2:#242427;
  --line:rgba(255,255,255,.07);
  --text:#f4f4f3;
  --muted:rgba(244,244,243,.55);
  --faint:rgba(244,244,243,.33);
  --accent:#f97316;
  --accent-bright:#fb923c;
  --accent-soft:rgba(249,115,22,.13);
  --accent-line:rgba(249,115,22,.45);
  --danger:#f4595f;
  --ok:#4ade80;
  --r-sm:8px;
  --r:12px;
  --r-lg:16px;
  --sidebar-w:225px;
  --bottnav-h:60px;
  color-scheme: dark;
}
[data-theme="light"]{
  --bg:#fafaf9;
  --surface:#f0efee;
  --surface-2:#e7e6e4;
  --line:rgba(20,18,14,.08);
  --text:#1c1b19;
  --muted:rgba(28,27,25,.58);
  --faint:rgba(28,27,25,.35);
  --accent:#ea580c;
  --accent-bright:#c2410c;
  --accent-soft:rgba(234,88,12,.10);
  --accent-line:rgba(234,88,12,.4);
  --ok:#16a34a;
  color-scheme: light;
}

*{ box-sizing:border-box; }
html,body{ margin:0; }
body{
  min-height:100vh;
  font-family:'Rubik',system-ui,-apple-system,Arial,sans-serif;
  font-size:14.5px;
  color:var(--text);
  background:var(--bg);
}
a{ color:var(--accent-bright); text-decoration:none; }
a:hover{ text-decoration:underline; }
button{ font-family:inherit; }
::selection{ background:var(--accent-soft); }
:focus-visible{ outline:2px solid var(--accent-line); outline-offset:2px; }

/* ------------------------------------------------ app frame */
.app{ display:grid; grid-template-columns:var(--sidebar-w) minmax(0,1fr); min-height:100vh; }

/* ------------------------------------------------ sidebar: part of the page, not a panel */
.sidebar{
  position:sticky; top:0; height:100vh;
  display:flex; flex-direction:column; gap:2px;
  padding:22px 14px 18px;
}
.brand{
  display:block; padding:2px 12px 22px;
  font-weight:600; font-size:17px; letter-spacing:.2px;
  color:var(--text); white-space:nowrap;
}
.brand:hover{ text-decoration:none; color:var(--text); }
.navlink{
  display:flex; align-items:center; gap:12px;
  padding:10px 14px; border-radius:999px;
  color:var(--muted); font-weight:500; font-size:14.5px;
  background:transparent; border:0;
  cursor:pointer; width:100%; text-align:left;
  transition:background .15s, color .15s;
}
.navlink:hover{ background:var(--surface); color:var(--text); text-decoration:none; }
.navlink.active{
  background:var(--accent-soft); color:var(--accent-bright);
  box-shadow:inset 0 0 0 1px rgba(249,115,22,.18), 0 0 22px rgba(249,115,22,.07);
}
.navlink svg{ flex:0 0 auto; }
.sideSection{ margin-top:auto; display:flex; flex-direction:column; gap:2px; }

/* theme rows (radio-style menu items) */
.themeItem{ position:relative; }
.themeItem .check{ margin-left:auto; color:var(--accent-bright); font-size:12px; }

/* account row + kebab menu */
.accountRow{ display:flex; align-items:center; gap:4px; margin-top:6px; position:relative; }
.accountRow .navlink{ flex:1; min-width:0; }
.accountRow .navlink span{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.kebab{
  width:34px; height:34px; border-radius:999px; flex:0 0 auto;
  display:grid; place-items:center;
  background:transparent; border:0; color:var(--muted); cursor:pointer;
}
.kebab:hover{ background:var(--surface); color:var(--text); }
.menu{
  position:absolute; bottom:44px; right:0; min-width:180px; z-index:50;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--r);
  padding:6px; box-shadow:0 16px 40px rgba(0,0,0,.45);
}
.menu a, .menu button{
  display:flex; align-items:center; gap:10px; width:100%;
  padding:9px 12px; border-radius:var(--r-sm);
  background:none; border:0; color:var(--text);
  font-size:13.5px; font-weight:500; cursor:pointer; text-align:left;
}
.menu a:hover, .menu button:hover{ background:var(--surface-2); text-decoration:none; }
.menu .danger{ color:var(--danger); }

.avatar{
  width:30px; height:30px; border-radius:50%; flex:0 0 auto;
  display:grid; place-items:center; overflow:hidden;
  background:var(--surface-2); color:var(--muted);
  font-weight:600; font-size:13px;
}
.avatar img{ width:100%; height:100%; object-fit:cover; }

/* ------------------------------------------------ mobile bars */
.mobileTop{ display:none; }
.bottomNav{ display:none; }

/* ------------------------------------------------ page scaffolding */
.page{ width:min(1420px,100%); margin:0 auto; padding:22px 26px 60px; }
.pageTitle{ font-size:23px; font-weight:600; margin:0 0 4px; letter-spacing:-.2px; }
.pageSub{ color:var(--muted); font-size:13.5px; margin:0 0 8px; }
.sectionTitle{ font-size:15px; font-weight:600; margin:0 0 4px; }

@keyframes riseIn{ from{ opacity:0; transform:translateY(10px);} to{ opacity:1; transform:none;} }
.rise{ animation:riseIn .45s cubic-bezier(.2,.7,.2,1) both; }
.rise-1{ animation-delay:.05s; } .rise-2{ animation-delay:.1s; }
@media (prefers-reduced-motion: reduce){ .rise{ animation:none; } }

/* ------------------------------------------------ top prompt bar */
.promptBar{
  display:flex; align-items:center; gap:8px;
  background:var(--surface); border-radius:14px;
  padding:5px 6px 5px 16px; margin-bottom:20px;
  border:1px solid transparent;
  transition:border-color .15s, box-shadow .15s;
}
.promptBar:focus-within{
  border-color:var(--accent-line);
  box-shadow:0 0 0 3px var(--accent-soft);
}
.promptBar svg{ color:var(--faint); flex:0 0 auto; }
.promptBar input{
  flex:1; min-width:0; height:44px;
  background:none; border:0; outline:none;
  color:var(--text); font-family:inherit; font-size:15px;
}
.promptBar input::placeholder{ color:var(--faint); }
.promptBar .go{
  height:38px; padding:0 16px; border-radius:10px; border:0;
  background:var(--accent); color:#fff; font-weight:600; font-size:13.5px;
  cursor:pointer; transition:background .15s;
}
.promptBar .go:hover{ background:var(--accent-bright); }

/* ------------------------------------------------ feed tabs */
.feedBar{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.feedTabs{ display:flex; gap:18px; }
.feedTabs button{
  background:none; border:0; padding:4px 0;
  color:var(--faint); font-size:15px; font-weight:600; cursor:pointer;
  transition:color .15s;
}
.feedTabs button:hover{ color:var(--muted); }
.feedTabs button.active{ color:var(--text); }
.modeToggle{ display:flex; gap:6px; }
.modeToggle button{
  display:inline-flex; align-items:center; gap:7px;
  padding:7px 14px; border-radius:999px; border:0;
  background:transparent; color:var(--muted);
  font-size:13.5px; font-weight:600; cursor:pointer;
  transition:background .15s,color .15s;
}
.modeToggle button:hover{ color:var(--text); background:var(--surface); }
.modeToggle button.active{ background:var(--accent-soft); color:var(--accent-bright); }

/* ------------------------------------------------ controls */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:9px 16px; border-radius:10px;
  border:0; background:var(--surface); color:var(--text);
  font-weight:600; font-size:13.5px; cursor:pointer;
  transition:background .15s, color .15s, transform .1s;
}
.btn:hover{ background:var(--surface-2); }
.btn:active{ transform:scale(.98); }
.btn:disabled{ opacity:.5; cursor:not-allowed; }
.btn.primary{ background:var(--accent); color:#fff; }
.btn.primary:hover{ background:var(--accent-bright); }
.btn.ghost{ background:transparent; color:var(--muted); }
.btn.ghost:hover{ background:var(--surface); color:var(--text); }
.btn.danger{ background:transparent; color:var(--danger); }
.btn.danger:hover{ background:rgba(244,89,95,.1); }
.btn.small{ padding:6px 12px; font-size:12.5px; border-radius:8px; }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], textarea, select{
  width:100%; padding:10px 13px;
  background:var(--surface); color:var(--text);
  border:1px solid transparent; border-radius:10px;
  font-family:inherit; font-size:14px; outline:none;
  transition:border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus{
  border-color:var(--accent-line); box-shadow:0 0 0 3px var(--accent-soft);
}
textarea{ resize:vertical; min-height:88px; line-height:1.55; }
label{ display:block; font-size:12px; font-weight:600; color:var(--muted); margin:0 0 6px; }
.field{ margin-bottom:14px; }
.hint{ font-size:12px; color:var(--faint); margin-top:5px; line-height:1.5; }

/* segmented control */
.seg{ display:flex; gap:4px; padding:3px; background:var(--surface); border-radius:10px; flex-wrap:wrap; }
.seg button{
  flex:1 1 auto; padding:7px 10px; min-width:46px;
  background:transparent; border:0; border-radius:8px;
  color:var(--muted); font-weight:600; font-size:12.5px; cursor:pointer;
  transition:background .15s,color .15s;
}
.seg button:hover{ color:var(--text); }
.seg button.active{ background:var(--surface-2); color:var(--accent-bright); }

.chip{
  display:inline-flex; align-items:center; gap:6px;
  padding:3px 10px; border-radius:999px;
  font-size:11.5px; font-weight:600;
  background:var(--accent-soft); color:var(--accent-bright);
}
.chip.gray{ background:var(--surface); color:var(--muted); }

.teamBadge{
  display:inline-flex; align-items:center; gap:6px;
  padding:3px 10px; border-radius:999px; margin-left:8px;
  font-size:11.5px; font-weight:600; vertical-align:middle;
  background:var(--accent-soft); color:var(--accent-bright);
}

.dot{ width:7px; height:7px; border-radius:50%; display:inline-block; flex:0 0 auto; }
.dot.on{ background:var(--ok); }
.dot.off{ background:var(--danger); }

/* toggle switch */
.switch{ position:relative; width:36px; height:20px; flex:0 0 auto; cursor:pointer; }
.switch input{ position:absolute; opacity:0; inset:0; margin:0; cursor:pointer; }
.switch .track{
  position:absolute; inset:0; border-radius:999px;
  background:var(--surface-2); transition:background .18s;
}
.switch .track::after{
  content:""; position:absolute; top:2px; left:2px;
  width:16px; height:16px; border-radius:50%;
  background:var(--muted); transition:transform .18s, background .18s;
}
.switch input:checked + .track{ background:var(--accent); }
.switch input:checked + .track::after{ transform:translateX(16px); background:#fff; }

.state{ min-height:18px; font-size:12.5px; color:var(--muted); line-height:1.5; }
.state.ok{ color:var(--ok); }
.state.bad{ color:var(--danger); }

/* ------------------------------------------------ image feed (dense masonry) */
.masonry{ columns:5 210px; column-gap:4px; }
.tile{
  position:relative; border-radius:9px; overflow:hidden;
  margin:0 0 4px; break-inside:avoid; display:block; width:100%;
  background:var(--surface); cursor:pointer;
}
.tile img{ width:100%; display:block; }
.tile .ov{
  position:absolute; inset:0; display:flex; align-items:flex-end;
  padding:10px; gap:8px;
  background:linear-gradient(to top, rgba(0,0,0,.62) 0%, rgba(0,0,0,0) 38%);
  opacity:0; transition:opacity .18s ease;
}
.tile:hover .ov, .tile:focus-within .ov{ opacity:1; }
.tile .ov .who{
  display:flex; align-items:center; gap:6px; min-width:0; flex:1;
  color:#fff; font-size:12.5px; font-weight:600;
}
.tile .ov .who a{ color:#fff; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tile .ov .who a:hover{ text-decoration:underline; }
.ovBtn{
  width:28px; height:28px; border-radius:999px; border:0; flex:0 0 auto;
  display:grid; place-items:center;
  background:rgba(255,255,255,.16); color:#fff; cursor:pointer;
  backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
  transition:background .15s, transform .1s;
}
.ovBtn:hover{ background:rgba(255,255,255,.3); }
.ovBtn:active{ transform:scale(.92); }
.ovBtn.liked{ background:var(--accent); }
.ovBtn.liked:hover{ background:var(--accent-bright); }
.ovBtn svg{ width:15px; height:15px; }

/* styles showcase grid (vertical cards) */
.stylesGrid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:8px; }
.styleCard{
  position:relative; display:block; border-radius:10px; overflow:hidden; margin:0;
  aspect-ratio:9/14; background:var(--surface); cursor:pointer; text-decoration:none;
}
.styleCard img{ width:100%; height:100%; object-fit:cover; display:block; transition:transform .3s; }
.styleCard:hover img{ transform:scale(1.04); }
.styleCard .cap{
  position:absolute; inset:auto 0 0 0; padding:24px 12px 10px;
  background:linear-gradient(to top, rgba(0,0,0,.7), transparent);
  color:#fff; font-size:13.5px; font-weight:600;
}
.styleCard .cap .desc{ display:block; font-size:11.5px; font-weight:400; color:rgba(255,255,255,.75); margin-top:2px; }

/* ------------------------------------------------ image detail modal */
.modal{
  position:fixed; inset:0; z-index:70; display:none;
  background:rgba(10,10,11,.9);
  backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
}
.modal.open{ display:flex; }
.modal .inner{
  margin:auto; display:flex; gap:0;
  width:min(1060px, calc(100% - 24px)); max-height:calc(100vh - 40px);
  background:var(--bg); border-radius:16px; overflow:hidden;
  box-shadow:0 30px 80px rgba(0,0,0,.6);
}
.modal .imgSide{
  flex:1; min-width:0; display:grid; place-items:center;
  background:#000;
}
.modal .imgSide img{ max-width:100%; max-height:calc(100vh - 40px); display:block; }
.modal .infoSide{
  width:320px; flex:0 0 auto; padding:20px;
  display:flex; flex-direction:column; gap:14px; overflow-y:auto;
}
.modal .creatorRow{ display:flex; align-items:center; gap:10px; }
.modal .creatorRow .nm{ font-weight:600; font-size:14px; }
.modal .creatorRow .nm a{ color:var(--text); }
.modal .promptText{
  font-size:13px; color:var(--muted); line-height:1.6;
  background:var(--surface); border-radius:10px; padding:12px;
  max-height:180px; overflow-y:auto; white-space:pre-wrap; word-break:break-word;
}
.modal .actions{ display:flex; flex-direction:column; gap:8px; }
.modalClose{
  position:absolute; top:14px; right:16px;
  width:38px; height:38px; border-radius:999px; border:0;
  background:rgba(255,255,255,.1); color:#fff; cursor:pointer;
  display:grid; place-items:center; z-index:2;
}
.modalClose:hover{ background:rgba(255,255,255,.22); }

/* ------------------------------------------------ minimal empty states */
.empty{
  padding:70px 20px; text-align:center;
  color:var(--faint); font-size:14px;
}
.empty .t{ color:var(--muted); font-weight:500; }
.empty .s{ font-size:12.5px; margin-top:4px; }
.empty a{ font-size:13px; }

/* ------------------------------------------------ simple rows (help/status) */
.rowLine{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:11px 2px; font-size:13.5px;
}
.rowLine + .rowLine{ border-top:1px solid var(--line); }
.rowLine .v{ color:var(--muted); display:flex; align-items:center; gap:8px; }

/* details/collapsible */
details.opt{ border-radius:10px; background:transparent; margin-bottom:12px; }
details.opt > summary{
  cursor:pointer; list-style:none; padding:10px 2px;
  font-size:13px; font-weight:600; color:var(--muted);
  display:flex; align-items:center; justify-content:space-between;
}
details.opt > summary:hover{ color:var(--text); }
details.opt > summary::-webkit-details-marker{ display:none; }
details.opt > summary::after{ content:"+"; font-size:15px; color:var(--faint); }
details.opt[open] > summary::after{ content:"–"; }
details.opt .inner{ padding:4px 2px 10px; }

/* ------------------------------------------------ helpers */
.row{ display:flex; align-items:center; gap:10px; }
.spread{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.wrap{ flex-wrap:wrap; }
.muted{ color:var(--muted); }
.faint{ color:var(--faint); }
.small{ font-size:12.5px; }
.num{ font-variant-numeric:tabular-nums; }
.hidden{ display:none !important; }
.divider{ height:1px; background:var(--line); margin:16px 0; border:0; }

@keyframes shimmer{ 0%{ background-position:200% 0; } 100%{ background-position:-200% 0; } }
.skel{
  border-radius:10px; min-height:80px;
  background:linear-gradient(90deg,var(--surface) 25%,var(--surface-2) 50%,var(--surface) 75%);
  background-size:200% 100%;
  animation:shimmer 1.4s linear infinite;
}
.btn.busy{
  background:linear-gradient(110deg,var(--accent) 30%,var(--accent-bright) 45%,var(--accent) 60%);
  background-size:200% 100%; animation:shimmer 1.2s linear infinite; color:#fff;
}

/* ------------------------------------------------ responsive: mobile */
@media (max-width: 959px){
  .app{ grid-template-columns:1fr; }
  .sidebar{ display:none; }

  .mobileTop{
    position:sticky; top:0; z-index:40;
    display:flex; align-items:center; justify-content:space-between;
    padding:12px 16px;
    background:color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px);
  }
  .mobileTop .brand{ padding:0; font-size:16px; }
  .mobileTop .actions{ display:flex; align-items:center; gap:8px; }
  .iconBtn{
    width:36px; height:36px; border-radius:999px; display:grid; place-items:center;
    background:var(--surface); border:0; color:var(--muted); cursor:pointer;
  }
  .iconBtn:active{ transform:scale(.95); }

  .bottomNav{
    position:fixed; bottom:0; left:0; right:0; z-index:40;
    display:grid; grid-template-columns:repeat(5,1fr);
    height:var(--bottnav-h);
    padding-bottom:env(safe-area-inset-bottom);
    background:color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px);
    border-top:1px solid var(--line);
  }
  .bottomNav a{
    display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px;
    color:var(--faint); font-size:10px; font-weight:600; text-decoration:none;
  }
  .bottomNav a.active{ color:var(--accent-bright); }
  .bottomNav a .createFab{
    width:42px; height:42px; border-radius:14px; display:grid; place-items:center;
    background:var(--accent); color:#fff; margin-top:-16px;
    box-shadow:0 8px 20px rgba(249,115,22,.35);
    border:3px solid var(--bg);
  }

  .page{ padding:16px 10px calc(var(--bottnav-h) + 40px); }
  .pageTitle{ font-size:20px; }
  .masonry{ columns:2 140px; column-gap:5px; }
  .tile{ margin-bottom:5px; border-radius:7px; }
  .tile .ov{ opacity:1; background:linear-gradient(to top, rgba(0,0,0,.5) 0%, rgba(0,0,0,0) 30%); }
  .stylesGrid{ grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:6px; }
  .modal .inner{ flex-direction:column; width:100%; height:100%; max-height:none; border-radius:0; margin:0; }
  .modal .imgSide img{ max-height:60vh; }
  .modal .infoSide{ width:100%; }
  .promptBar input{ height:40px; font-size:14px; }
}
