/* ===========================
   Digital Library - AI Hub style
   Light blue glassmorphism RTL
   =========================== */

*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root{
  --bg-top:#d5e6ff;
  --bg-mid:#e8f2ff;
  --bg-bot:#f5f9ff;
  --surface:rgba(255,255,255,.68);
  --surface-solid:#ffffff;
  --surface-2:#f0f6ff;
  --border:rgba(255,255,255,.85);
  --primary:#1e50a0;
  --primary-2:#2a7dff;
  --primary-grad:linear-gradient(135deg,#2a7dff 0%,#1e50a0 100%);
  --primary-grad-soft:linear-gradient(135deg,#5ba4ff 0%,#2a7dff 100%);
  --purple:#6c5ce7;
  --purple-soft:rgba(108,92,231,.14);
  --teal:#00b894;
  --teal-soft:rgba(0,184,148,.14);
  --danger:#e74c3c;
  --highlight:#e74c3c;
  --text:#102a54;
  --text-soft:#5b7399;
  --text-muted:#8a9cbb;
  --shadow-card:0 8px 28px rgba(30,80,160,.10),0 2px 6px rgba(30,80,160,.06);
  --shadow-lg:0 18px 50px rgba(30,80,160,.18);
  --radius-xl:28px;
  --radius-lg:22px;
  --radius-md:18px;
  --radius-sm:14px;
  --fs:16px;
  --font:'Tahoma','Arial',system-ui,-apple-system,sans-serif;
}
[data-theme="dark"]{
  --bg-top:#0f1a2f;--bg-mid:#122242;--bg-bot:#1a2d52;
  --surface:rgba(30,44,78,.75);--surface-solid:#1f2f52;--surface-2:#25375e;
  --border:rgba(255,255,255,.08);
  --text:#e6eeff;--text-soft:#b3c3e5;--text-muted:#7d8fba;
  --primary:#5ba4ff;--primary-2:#7ab8ff;
  --primary-grad:linear-gradient(135deg,#3d8bff 0%,#1e50a0 100%);
  --shadow-card:0 8px 28px rgba(0,0,0,.4);
  --shadow-lg:0 18px 50px rgba(0,0,0,.5);
}
[data-theme="sepia"]{
  --bg-top:#f2e5c8;--bg-mid:#f7ecda;--bg-bot:#fbf5e9;
  --surface:rgba(255,250,235,.85);--surface-solid:#fbf5e9;--surface-2:#f0e6d0;
  --border:rgba(180,140,80,.2);
  --primary:#8a5a2b;--primary-2:#b8860b;
  --primary-grad:linear-gradient(135deg,#d4a259 0%,#8a5a2b 100%);
  --text:#4a3520;--text-soft:#7a5c3a;--text-muted:#a88a66;
  --shadow-card:0 8px 28px rgba(120,80,30,.12);
  --shadow-lg:0 18px 50px rgba(120,80,30,.2);
}

html,body{height:100%;width:100%;overflow:hidden}
body{
  font-family:var(--font);font-size:var(--fs);
  color:var(--text);direction:rtl;-webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;line-height:1.6;
  background:var(--bg-bot);
}
button,input{font-family:inherit;color:inherit;border:none;background:none;outline:none;font-size:inherit}
button{cursor:pointer}

/* ===== App shell ===== */
#app{
  height:100vh;height:100dvh;max-width:480px;margin:0 auto;
  position:relative;overflow:hidden;
}
.app-bg{
  background:linear-gradient(180deg,var(--bg-top) 0%,var(--bg-mid) 45%,var(--bg-bot) 100%);
}

/* ===== Screens ===== */
.screen{
  position:absolute;inset:0;display:flex;flex-direction:column;
  opacity:0;pointer-events:none;transform:translateX(12px);
  transition:opacity .28s ease,transform .28s ease;
}
.screen.active{opacity:1;pointer-events:auto;transform:translateX(0)}
.scroll-area{
  flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;
  padding-bottom:120px;padding-top:0;
}
.sub-scroll{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:16px;padding-bottom:120px}

/* ============== HEADER ============== */
.header{
  position:relative;
  display:flex;align-items:flex-start;justify-content:space-between;
  padding:18px 20px 10px;
  padding-top:calc(18px + env(safe-area-inset-top));
}
.header-brand{display:flex;align-items:center;gap:12px}
.brand-icon{
  width:56px;height:56px;border-radius:16px;
  background:var(--surface);
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  border:1px solid var(--border);
  display:flex;align-items:center;justify-content:center;
  box-shadow:var(--shadow-card);flex-shrink:0;
}
.brand-icon svg{width:38px;height:38px}
.brand-title{
  font-size:1.65rem;font-weight:800;
  background:var(--primary-grad);-webkit-background-clip:text;
  -webkit-text-fill-color:transparent;background-clip:text;
  line-height:1.2;
}
.brand-sub{font-size:.82rem;color:var(--text-soft);margin-top:3px}
.settings-round{
  width:54px;height:54px;border-radius:50%;
  background:#fff;
  display:flex;align-items:center;justify-content:center;
  box-shadow:var(--shadow-card);flex-shrink:0;
  border:1px solid rgba(255,255,255,.9);
  transition:transform .15s;
}
.settings-round:active{transform:scale(.92)}
.settings-round svg{width:26px;height:26px}
.header-left{display:flex;align-items:center;gap:8px}

/* ============== HERO ============== */
.hero{
  position:relative;
  padding:8px 24px 18px;
  min-height:270px;
  overflow:hidden;
}
.hero-orb{
  position:absolute;left:-60px;top:-50px;width:360px;height:360px;
  background:radial-gradient(circle,rgba(91,164,255,.65) 0%,rgba(42,125,255,0) 70%);
  border-radius:50%;z-index:0;pointer-events:none;
}
.hero-wave{
  position:absolute;right:-20%;top:10%;width:400px;height:400px;
  background:radial-gradient(circle,rgba(120,180,255,.45) 0%,rgba(42,125,255,0) 60%);
  border-radius:50%;z-index:0;pointer-events:none;
}
.hero-robot{
  position:absolute;right:-10px;top:-5px;
  width:240px;height:240px;
  object-fit:contain;
  z-index:1;
  filter: drop-shadow(0 18px 30px rgba(30,80,160,.30));
  animation:bob 3.5s ease-in-out infinite;
  transform:scaleX(-1);
}
@keyframes bob{0%,100%{transform:translateY(0) rotate(-1deg)}50%{transform:translateY(-8px) rotate(1deg)}}
.sparkle{
  position:absolute;width:10px;height:10px;background:#fff;border-radius:50%;
  box-shadow:0 0 12px #fff,0 0 24px rgba(255,255,255,.6);
  z-index:1;animation:twinkle 2s ease-in-out infinite;
}
.sp1{right:18%;top:20px;animation-delay:.2s}
.sp2{right:30%;top:50px;width:6px;height:6px;animation-delay:.8s}
.sp3{left:40%;top:10px;width:6px;height:6px;animation-delay:1.4s}
@keyframes twinkle{0%,100%{opacity:.3;transform:scale(.8)}50%{opacity:1;transform:scale(1.2)}}
.hero-title{
  position:relative;z-index:2;
  margin-left:220px;
  margin-top:30px;
  font-size:1.6rem;font-weight:800;
  color:var(--primary);
  line-height:1.5;
  text-align:right;
}
.hero-desc{
  position:relative;z-index:2;
  margin-left:220px;
  margin-top:12px;
  font-size:.95rem;color:var(--text-soft);
  line-height:2;
  text-align:right;
}
.hero-underline{
  display:block;width:80px;height:3px;margin-top:10px;
  background:var(--primary-grad);border-radius:2px;margin-right:auto;margin-left:0;
}

/* ============== SEARCH ============== */
.search-wrap{padding:4px 20px 10px;position:relative;z-index:3}
.search-box{
  display:flex;align-items:center;gap:10px;
  background:#fff;border-radius:999px;
  padding:8px 8px 8px 8px;
  box-shadow:var(--shadow-card);
  border:1px solid rgba(255,255,255,.9);
  height:60px;
}
.search-icon{
  width:46px;height:46px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.search-icon svg{width:24px;height:24px}
.search-box input{
  flex:1;height:100%;
  font-size:1rem;text-align:right;padding:0 4px;
  color:var(--text);
}
.search-box input::placeholder{color:var(--text-muted)}
.send-btn{
  width:46px;height:46px;border-radius:50%;
  background:var(--primary-grad);color:#fff;
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 6px 14px rgba(30,80,160,.35);
  transition:transform .12s;flex-shrink:0;
}
.send-btn:active{transform:scale(.92)}
.send-btn svg{width:22px;height:22px}

/* ============== CHIPS ============== */
.chips{
  display:flex;gap:8px;overflow-x:auto;
  padding:4px 20px 10px;scrollbar-width:none;
  position:relative;z-index:3;
}
.chips::-webkit-scrollbar{display:none}
.chip{
  flex-shrink:0;padding:8px 16px;border-radius:999px;
  background:rgba(255,255,255,.8);
  color:var(--primary);font-weight:600;font-size:.83rem;
  border:1px solid rgba(42,125,255,.18);
  backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);
  transition:all .2s;
}
.chip:hover{background:#fff;box-shadow:var(--shadow-card)}

/* ============== CATEGORY SECTION ============== */
.cat-section{padding:8px 20px 4px;position:relative;z-index:3}
.cat-section-title{
  font-size:.9rem;font-weight:700;color:var(--text-soft);
  margin-bottom:12px;margin-right:4px;
}
.cat-grid{
  display:grid;grid-template-columns:repeat(3,1fr);gap:12px;
}
.cat-card{
  background:var(--surface);
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:16px 8px 14px;
  text-align:center;
  box-shadow:var(--shadow-card);
  cursor:pointer;
  transition:transform .12s,box-shadow .2s;
  position:relative;overflow:hidden;
  display:flex;flex-direction:column;align-items:center;gap:8px;
}
.cat-card::before{
  content:"";position:absolute;inset:auto 0 0 0;height:40%;
  background:linear-gradient(180deg,rgba(91,164,255,0),rgba(91,164,255,.14));
  pointer-events:none;
}
.cat-card:active{transform:scale(.96);box-shadow:var(--shadow-lg)}
.cat-icon{
  width:60px;height:60px;
  display:flex;align-items:center;justify-content:center;
  filter:drop-shadow(0 6px 14px rgba(30,80,160,.28));
  font-size:2.2rem;line-height:1;
}
.cat-icon svg{width:62px;height:62px;display:block}
.cat-name{
  font-size:.85rem;font-weight:700;color:var(--text);
  line-height:1.4;
}
.cat-count{
  font-size:.7rem;color:var(--text-muted);margin-top:2px;
}

/* ============== ACTION BUTTONS ============== */
.action-row{
  display:grid;grid-template-columns:1fr 1fr;gap:12px;
  padding:16px 20px 10px;position:relative;z-index:3;
}
.action-btn{
  display:flex;align-items:center;gap:10px;
  padding:14px 14px;border-radius:var(--radius-lg);
  text-align:right;
  transition:transform .12s,box-shadow .2s;
}
.action-btn:active{transform:scale(.97)}
.action-fill{
  background:var(--primary-grad);color:#fff;
  box-shadow:0 10px 24px rgba(30,80,160,.28);
}
.action-outline{
  background:var(--surface);
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  border:2px solid rgba(42,125,255,.35);
  box-shadow:var(--shadow-card);
}
.action-icon-blue,.action-icon-white{
  width:42px;height:42px;border-radius:12px;
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.action-icon-blue{background:rgba(30,80,160,.1)}
.action-icon-white{background:rgba(255,255,255,.25)}
.action-icon-blue svg{width:22px;height:22px}
.action-icon-white svg{width:22px;height:22px}
.action-btn span{flex:1;display:flex;flex-direction:column;min-width:0}
.action-title{font-size:.9rem;font-weight:800;line-height:1.3}
.action-sub{font-size:.72rem;opacity:.8;margin-top:2px}
.action-outline .action-title{color:var(--primary)}
.action-outline .action-sub{color:var(--text-soft)}

/* ============== INFO BUTTONS ============== */
.info-row{
  display:grid;grid-template-columns:1fr 1fr;gap:12px;
  padding:4px 20px 8px;position:relative;z-index:3;
}
.info-btn{
  display:flex;align-items:center;gap:10px;
  padding:14px;border-radius:var(--radius-lg);
  text-align:right;
  position:relative;overflow:hidden;
  transition:transform .12s;
}
.info-btn:active{transform:scale(.97)}
.info-purple{
  background:var(--surface);
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  border:1px solid var(--border);
  box-shadow:var(--shadow-card);
}
.info-purple::after{
  content:"";position:absolute;left:0;bottom:0;width:60px;height:40px;
  background:radial-gradient(circle at 20% 100%,rgba(108,92,231,.3) 0%,transparent 70%);
  border-radius:0 0 0 var(--radius-lg);
}
.info-teal{
  background:var(--surface);
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  border:1px solid var(--border);
  box-shadow:var(--shadow-card);
}
.info-teal::after{
  content:"";position:absolute;right:0;bottom:0;width:60px;height:40px;
  background:radial-gradient(circle at 80% 100%,rgba(0,184,148,.3) 0%,transparent 70%);
  border-radius:0 0 var(--radius-lg) 0;
}
.info-icon-teal{
  width:38px;height:38px;border-radius:12px;
  background:var(--teal-soft);color:var(--teal);
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.info-icon-purple{
  width:38px;height:38px;border-radius:12px;
  background:var(--purple-soft);color:var(--purple);
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.info-icon-teal svg,.info-icon-purple svg{width:20px;height:20px}
.info-btn > span:nth-of-type(1){flex:1;display:flex;flex-direction:column}
.info-title{font-size:.88rem;font-weight:800;color:var(--text)}
.info-sub{font-size:.7rem;color:var(--text-soft);margin-top:2px}
.info-arrow{width:18px;height:18px;flex-shrink:0}

/* ============== BOTTOM SPACER ============== */
.bottom-spacer{height:20px}

/* ============== BOTTOM NAV (capsule) ============== */
.bottom-nav{
  position:absolute;left:12px;right:12px;bottom:14px;
  padding-bottom:env(safe-area-inset-bottom);
  height:72px;
  background:#fff;
  border-radius:999px;
  display:grid;grid-template-columns:repeat(5,1fr);
  align-items:center;justify-items:center;
  box-shadow:0 10px 32px rgba(30,80,160,.18);
  z-index:50;
}
.bn-btn{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:2px;color:var(--text-muted);flex:1;height:100%;
  transition:color .2s,transform .12s;
}
.bn-btn svg{width:22px;height:22px}
.bn-btn span{font-size:.66rem;font-weight:600}
.bn-btn.active:not(.bn-home){color:var(--primary-2)}
.bn-home{
  width:58px;height:58px;border-radius:50%;
  background:var(--primary-grad);
  color:#fff;
  box-shadow:0 8px 22px rgba(30,80,160,.45);
  margin-top:-22px;
  transition:transform .12s;
}
.bn-home:active{transform:scale(.94)}
.bn-home svg{width:28px;height:28px}
.bn-home span{display:none}

/* ============== SUB HEADER (detail/settings/about/stats) ============== */
.sub-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px 16px;
  padding-top:calc(14px + env(safe-area-inset-top));
  gap:8px;flex-shrink:0;
  background:transparent;
}
.sub-back,.sub-add{
  width:44px;height:44px;border-radius:50%;
  background:#fff;
  display:flex;align-items:center;justify-content:center;
  box-shadow:var(--shadow-card);flex-shrink:0;
  transition:transform .12s;
}
.sub-add.placeholder{visibility:hidden}
.sub-back:active,.sub-add:active{transform:scale(.92)}
.sub-back svg,.sub-add svg{width:22px;height:22px}
.sub-title{
  flex:1;text-align:center;font-size:1.1rem;font-weight:800;
  color:var(--primary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}

/* ============== SUMMARIES LIST ============== */
.summaries-list{display:flex;flex-direction:column;gap:12px;padding-bottom:4px}
.summary-card{
  background:var(--surface-solid);border-radius:var(--radius-md);
  padding:16px;box-shadow:var(--shadow-card);
  border:1px solid var(--border);position:relative;cursor:pointer;
  transition:transform .12s;
}
.summary-card:active{transform:scale(.98)}
.s-title{font-weight:800;color:var(--primary);font-size:1rem;margin-bottom:4px;padding-left:40px}
.s-author{font-size:.82rem;color:var(--text-soft);margin-bottom:8px;padding-left:40px}
.s-date{font-size:.72rem;color:var(--text-muted)}
.s-del{
  position:absolute;top:10px;left:10px;width:36px;height:36px;border-radius:10px;
  display:flex;align-items:center;justify-content:center;color:var(--text-muted);
  background:var(--surface-2);transition:all .2s;
}
.s-del:hover{color:var(--danger);background:rgba(231,76,60,.1)}
.s-del svg{width:18px;height:18px}
.empty-state{
  text-align:center;padding:50px 20px;color:var(--text-muted);
  background:var(--surface);border-radius:var(--radius-lg);
  backdrop-filter:blur(12px);border:1px solid var(--border);
}
.empty-icon{font-size:60px;margin-bottom:14px}

/* ============== READER ============== */
.reader-scroll{padding:0 4px 10px}
.reader-content{
  background:var(--surface-solid);border-radius:var(--radius-lg);
  padding:24px 22px;margin:4px 8px 0;
  box-shadow:var(--shadow-card);border:1px solid var(--border);
}
.book-header{text-align:center;padding:10px 0 24px;border-bottom:2px solid rgba(42,125,255,.15);margin-bottom:24px}
.book-title{
  font-size:1.55rem;font-weight:800;line-height:1.5;margin-bottom:8px;
  background:var(--primary-grad);-webkit-background-clip:text;
  -webkit-text-fill-color:transparent;background-clip:text;
}
.book-author{font-size:.92rem;color:var(--text-soft)}
.book-author strong{color:var(--text)}
.book-section{margin-bottom:26px}
.section-heading{
  font-size:1.08rem;font-weight:800;margin-bottom:12px;
  padding:6px 14px;display:inline-block;
  background:var(--primary-grad);color:#fff;border-radius:12px;
}
.section-body{font-size:1.02rem;line-height:2.3;text-align:justify;color:var(--text)}
.key-point{color:var(--highlight);font-weight:700;background:linear-gradient(transparent 70%,rgba(231,76,60,.15) 70%)}
.reading-time{
  text-align:center;padding:14px;margin-top:24px;
  background:var(--surface-2);border-radius:var(--radius-sm);
  color:var(--text-soft);font-size:.85rem;
  border:2px dashed rgba(42,125,255,.25);
}

/* ============== SETTINGS ============== */
.settings-content{display:flex;flex-direction:column;gap:12px}
.set-card{
  background:var(--surface-solid);border-radius:var(--radius-lg);
  padding:18px;box-shadow:var(--shadow-card);border:1px solid var(--border);
}
.set-card h3{font-size:.88rem;font-weight:700;color:var(--text-soft);margin-bottom:14px}
.theme-row{display:flex;gap:8px}
.theme-pill{
  flex:1;padding:11px;border-radius:14px;
  background:var(--surface-2);border:2px solid transparent;
  font-weight:700;font-size:.85rem;color:var(--text);
  display:flex;align-items:center;justify-content:center;gap:6px;
  transition:all .2s;
}
.theme-pill.active{border-color:var(--primary-2);background:rgba(42,125,255,.1);color:var(--primary)}
.dot{width:14px;height:14px;border-radius:50%;display:inline-block}
.light-dot{background:#e8f2ff;border:1px solid #b8d0f0}
.dark-dot{background:#1a2d52}
.sepia-dot{background:#f4ecd8;border:1px solid #c8b488}

.slider-row{display:flex;align-items:center;gap:12px}
.slider-row .fs-sm{font-size:.85rem;color:var(--text-muted)}
.slider-row .fs-lg{font-size:1.25rem;font-weight:700;color:var(--primary)}
.slider-row input[type=range]{
  flex:1;-webkit-appearance:none;appearance:none;height:8px;border-radius:4px;
  background:linear-gradient(90deg,var(--primary-2),var(--primary));outline:none;
}
.slider-row input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none;width:24px;height:24px;border-radius:50%;
  background:#fff;box-shadow:0 4px 12px rgba(30,80,160,.4);
  border:3px solid var(--primary-2);cursor:pointer;
}
.mini-note{font-size:.75rem;color:var(--text-muted);text-align:center;margin-top:8px}
.color-row{display:flex;gap:10px;flex-wrap:wrap}
.swatch{
  width:40px;height:40px;border-radius:50%;
  border:3px solid rgba(255,255,255,.9);
  box-shadow:var(--shadow-card);cursor:pointer;transition:transform .15s,border-color .2s;
}
.swatch.active{border-color:var(--primary-2);transform:scale(1.15)}

.set-link{
  display:flex;align-items:center;justify-content:space-between;
  background:var(--surface-solid);border-radius:var(--radius-lg);
  padding:16px 18px;box-shadow:var(--shadow-card);border:1px solid var(--border);
  font-weight:700;color:var(--text);font-size:.92rem;
  transition:transform .12s;
}
.set-link:active{transform:scale(.98)}
.set-link svg{width:18px;height:18px}
.set-link.danger{color:var(--danger);justify-content:center}

/* ============== ABOUT ============== */
.about-content{display:flex;flex-direction:column;gap:12px}
.about-hero{
  text-align:center;padding:18px;background:var(--surface-solid);
  border-radius:var(--radius-lg);box-shadow:var(--shadow-card);border:1px solid var(--border);
}
.about-hero img{width:90px;height:90px;border-radius:24px;margin-bottom:10px;box-shadow:var(--shadow-card)}
.about-hero h2{font-size:1.3rem;font-weight:800;background:var(--primary-grad);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}
.about-hero .ver{font-size:.78rem;color:var(--text-muted);margin-top:4px}
.about-card{
  background:var(--surface-solid);border-radius:var(--radius-lg);
  padding:18px;box-shadow:var(--shadow-card);border:1px solid var(--border);
}
.about-card h3{font-size:.9rem;font-weight:700;color:var(--primary);margin-bottom:10px}
.about-card p{font-size:.88rem;line-height:2.1;color:var(--text);margin-bottom:8px}

/* ============== STATS ============== */
.stats-content{display:flex;flex-direction:column;gap:12px}
.stat-row{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.stat-box{
  background:var(--surface-solid);border-radius:var(--radius-md);
  padding:16px 8px;text-align:center;box-shadow:var(--shadow-card);border:1px solid var(--border);
}
.stat-box .n{display:block;font-size:1.6rem;font-weight:800;background:var(--primary-grad);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;line-height:1}
.stat-box .l{display:block;font-size:.72rem;color:var(--text-muted);margin-top:6px;font-weight:600}
.chart-card{
  background:var(--surface-solid);border-radius:var(--radius-lg);
  padding:18px;box-shadow:var(--shadow-card);border:1px solid var(--border);
}
.chart-card h3{font-size:.9rem;font-weight:700;color:var(--text);margin-bottom:14px}
#chart-container{max-height:380px;overflow-y:auto;padding-left:2px}
.chart-row{display:flex;align-items:center;gap:10px;margin-bottom:10px}
.chart-label{
  min-width:80px;max-width:100px;font-size:.78rem;text-align:left;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:0;color:var(--text);
}
.chart-track{flex:1;height:26px;background:var(--surface-2);border-radius:14px;overflow:hidden;position:relative}
.chart-fill{height:100%;border-radius:14px;background:var(--primary-grad-soft);transition:width .7s cubic-bezier(.4,0,.2,1);min-width:4px}
.chart-val{position:absolute;left:10px;top:50%;transform:translateY(-50%);font-size:.72rem;font-weight:700;color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.3)}

/* ============== MODAL ============== */
.modal{
  position:absolute;inset:0;background:rgba(16,42,84,.4);backdrop-filter:blur(6px);
  display:flex;align-items:flex-end;justify-content:center;z-index:100;
  animation:fadeIn .25s;
}
.modal.hidden{display:none}
.modal-card{
  width:100%;max-width:480px;background:#fff;
  border-radius:var(--radius-xl) var(--radius-xl) 0 0;
  padding:20px;padding-bottom:calc(20px + env(safe-area-inset-bottom));
  animation:slideUp .3s cubic-bezier(.4,0,.2,1);
}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
@keyframes slideUp{from{transform:translateY(100%)}to{transform:translateY(0)}}
.modal-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}
.modal-head h3{font-size:1.05rem;font-weight:800;color:var(--primary)}
.modal-close{width:36px;height:36px;border-radius:50%;background:var(--surface-2);display:flex;align-items:center;justify-content:center;color:var(--text-soft);font-size:1rem}
.manage-list{display:flex;flex-direction:column;gap:8px;max-height:50vh;overflow-y:auto}
.manage-item{
  display:flex;align-items:center;justify-content:space-between;
  padding:12px 14px;border-radius:var(--radius-sm);background:var(--surface-2);
}
.manage-item span{font-weight:600}
.manage-item button{color:var(--danger);font-size:.82rem;font-weight:700;padding:6px 12px;border-radius:8px;background:rgba(231,76,60,.1)}
.add-body{display:flex;flex-direction:column;gap:12px}
.add-body input{padding:14px 16px;border-radius:var(--radius-sm);background:var(--surface-2);font-size:.95rem}
.add-confirm{
  padding:14px;border-radius:var(--radius-sm);background:var(--primary-grad);color:#fff;
  font-weight:700;font-size:.95rem;box-shadow:0 8px 20px rgba(30,80,160,.3);
}

/* ============== LOADING ============== */
.loading{
  position:absolute;inset:0;background:rgba(232,242,255,.85);backdrop-filter:blur(8px);
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  z-index:200;gap:18px;
}
[data-theme="dark"] .loading{background:rgba(15,26,47,.85)}
[data-theme="sepia"] .loading{background:rgba(247,236,218,.85)}
.loading.hidden{display:none}
.spinner{
  width:54px;height:54px;border:4px solid rgba(42,125,255,.2);
  border-top-color:var(--primary-2);border-radius:50%;
  animation:spin 1s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}
.loading p{font-size:.9rem;color:var(--text-soft);font-weight:600}

/* ============== TOAST ============== */
.toast{
  position:fixed;bottom:100px;left:50%;transform:translateX(-50%) translateY(20px);
  background:#fff;color:var(--text);
  padding:12px 20px;border-radius:14px;
  font-size:.85rem;font-weight:600;
  opacity:0;pointer-events:none;transition:all .3s;
  z-index:2000;max-width:90%;text-align:center;
  box-shadow:var(--shadow-lg);
}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
.toast.error{background:var(--danger);color:#fff}
.toast.success{background:var(--teal);color:#fff}

/* ============== Responsive ============== */
@media(min-width:481px){
  #app{border-radius:32px;margin:12px auto;height:calc(100vh - 24px);height:calc(100dvh - 24px);overflow:hidden}
}
