*{box-sizing:border-box;margin:0;padding:0}
:root{--bg:#07111f;--bg2:#0d1831;--text:#edf4ff;--muted:#aab8d5;--line:rgba(255,255,255,.12);--glass:rgba(255,255,255,.08);--glass-soft:rgba(255,255,255,.05);--primary:#7c5cff;--secondary:#00d4ff;--accent:#ff5ea8;--shadow:0 24px 70px rgba(0,0,0,.34)}
body.light{--bg:#eef3ff;--bg2:#dfe8ff;--text:#121a2c;--muted:#5b677f;--line:rgba(17,26,44,.12);--glass:rgba(255,255,255,.78);--glass-soft:rgba(255,255,255,.68);--shadow:0 20px 55px rgba(39,59,95,.18)}
html{scroll-behavior:smooth}
body{font-family:Inter,system-ui,Arial,sans-serif;min-height:100vh;color:var(--text);background:radial-gradient(circle at top left, rgba(124,92,255,.2), transparent 24%),radial-gradient(circle at top right, rgba(0,212,255,.16), transparent 20%),linear-gradient(135deg,var(--bg),var(--bg2));overflow-x:hidden}
.shell{width:min(1180px, calc(100% - 40px));margin-inline:auto}
.bg-orb{position:fixed;border-radius:50%;filter:blur(80px);opacity:.24;pointer-events:none;z-index:-1}
.orb-a{width:280px;height:280px;background:var(--primary);top:-40px;left:-60px}
.orb-b{width:320px;height:320px;background:var(--secondary);top:120px;right:-100px}
.bg-grid{position:fixed;inset:0;pointer-events:none;z-index:-2;background-image:linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);background-size:34px 34px;mask-image:radial-gradient(circle at center, black 40%, transparent 88%)}
.glass-card,.glass-soft{background:var(--glass);border:1px solid var(--line);box-shadow:var(--shadow);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px)}
.glass-card{border-radius:28px}
.glass-soft{border-radius:22px;background:var(--glass-soft)}
.topbar{display:flex;justify-content:space-between;align-items:center;gap:18px;padding:22px 0 16px}
.brand{display:flex;align-items:center;gap:14px}
.logo{width:60px;height:60px;border-radius:18px;display:grid;place-items:center;font-weight:800;color:#fff;background:linear-gradient(135deg,var(--primary),var(--secondary))}
.brand h1{font-size:1.15rem}.brand p{color:var(--muted);font-size:.94rem}
.top-actions{display:flex;gap:10px}
.ghost-btn,.primary-btn,.swap-btn{border:none;cursor:pointer;transition:.25s ease;border-radius:16px;padding:12px 16px;font-weight:700}
.ghost-btn{background:var(--glass-soft);color:var(--text);border:1px solid var(--line)}
.primary-btn{background:linear-gradient(135deg,var(--primary),var(--secondary));color:#fff}
.swap-btn{width:56px;height:56px;padding:0;font-size:1.15rem;color:#fff;background:linear-gradient(135deg,var(--primary),var(--accent))}
.small-btn{padding:10px 14px;font-size:.94rem}.voice-btn{min-width:128px}
.ghost-btn:hover,.primary-btn:hover,.swap-btn:hover,.chip:hover,.quick-card:hover{transform:translateY(-2px)}
.hero{display:grid;grid-template-columns:1fr 1fr;gap:18px;padding:26px}
.tag{display:inline-block;padding:8px 12px;border-radius:999px;margin-bottom:16px;font-size:.84rem;border:1px solid var(--line);background:rgba(124,92,255,.15)}
.hero-copy h2{font-size:clamp(2rem,4.7vw,3.8rem);line-height:1.02;margin-bottom:14px}
.hero-copy p,.subtle{color:var(--muted);line-height:1.75}
.hero-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:22px}
.hero-stats article{padding:16px;border-radius:20px;background:var(--glass-soft);border:1px solid var(--line)}
.hero-stats strong{display:block;margin-bottom:6px}.hero-stats span{color:var(--muted);font-size:.92rem}
.hero-preview{padding:22px;display:flex;flex-direction:column;justify-content:center}
.eyebrow{font-size:.86rem;color:var(--muted);margin-bottom:8px}
.hero-preview h3{font-size:1.6rem;line-height:1.25;margin-bottom:10px}
.main-grid{margin-top:18px;display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:20px;align-items:start}
.workspace{display:flex;flex-direction:column;gap:20px}
.converter{padding:22px}.chart-box{padding:20px}
.section-top{display:grid;grid-template-columns:minmax(0,1fr) minmax(260px,360px);gap:16px;align-items:end;margin-bottom:16px}
.section-top p,.section-head-inline p{color:var(--muted)}
.section-top input,.field input,.field select{width:100%;padding:15px 16px;border-radius:16px;border:1px solid var(--line);background:rgba(255,255,255,.06);color:var(--text);outline:none;font-size:1rem}
body.light .section-top input,body.light .field input,body.light .field select{background:rgba(255,255,255,.9)}
.field select option{color:#111}
.chips{display:flex;gap:10px;overflow:auto;padding-bottom:8px;margin-bottom:16px}
.chip{white-space:nowrap;border:none;padding:10px 14px;border-radius:999px;background:var(--glass-soft);color:var(--text);border:1px solid var(--line);cursor:pointer}
.chip.active{background:linear-gradient(135deg,var(--primary),var(--secondary));color:#fff}
.form-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;align-items:end}
.field label{display:block;margin-bottom:8px;color:var(--muted);font-size:.92rem}
.field-span-2{grid-column:span 2}
.value-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px}
.swap-wrap{display:flex;justify-content:center;align-items:end;padding-bottom:2px}
.result-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:18px}
.result-card{padding:20px}
.result-card h2{font-size:clamp(1.9rem,4vw,3rem);margin:8px 0 10px;word-break:break-word}
.result-card p{line-height:1.7}
.action-row{display:flex;flex-wrap:wrap;gap:10px;margin-top:14px}
.section-head-inline{margin-bottom:12px}
.sidebar{display:flex;flex-direction:column;gap:20px}
.panel{padding:18px}
.chart-box {
  padding:20px;
  height:300px;
  max-height:300px;
}
.panel-top{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:14px}
.quick-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.quick-card{text-align:left;padding:14px;border-radius:18px;border:1px solid var(--line);background:var(--glass-soft);color:var(--text);cursor:pointer}
.quick-card span{display:block;color:var(--muted);font-size:.82rem;margin-bottom:7px}.quick-card strong{line-height:1.45}
.item-list{list-style:none;display:flex;flex-direction:column;gap:10px;max-height:260px;overflow:auto}
.item-list li{padding:12px 14px;border-radius:16px;background:var(--glass-soft);border:1px solid var(--line);line-height:1.55}
.footer{padding:22px 0 30px;color:var(--muted);text-align:center}
@media (max-width:1080px){.main-grid{grid-template-columns:1fr}.sidebar{display:grid;grid-template-columns:1fr}}
@media (max-width:820px){.hero,.result-grid,.section-top{grid-template-columns:1fr}.form-grid{grid-template-columns:1fr}.field-span-2{grid-column:span 1}.swap-wrap{justify-content:flex-start}.hero-stats,.quick-grid{grid-template-columns:1fr}}
@media (max-width:560px){.shell{width:min(100% - 20px, 1180px)}.topbar{flex-direction:column;align-items:flex-start}.value-row{grid-template-columns:1fr}.top-actions,.action-row{width:100%}.top-actions .ghost-btn,.action-row .ghost-btn,.voice-btn,.primary-btn{width:100%}}
.site-nav{
  display:flex;
  gap:16px;
  flex-wrap:wrap;
  align-items:center;
}

.site-nav a{
  color:var(--text);
  text-decoration:none;
  font-weight:600;
  opacity:.92;
}

.site-nav a:hover{
  opacity:1;
  text-decoration:underline;
}

.page-content{
  display:flex;
  flex-direction:column;
  gap:20px;
  padding:18px 0 30px;
}

.page-hero,
.content-block{
  padding:24px;
}

.page-hero h2,
.content-block h2,
.content-block h3{
  margin-bottom:12px;
}

.page-hero p,
.content-block p,
.content-block li{
  color:var(--muted);
  line-height:1.8;
}

.content-block ul{
  padding-left:20px;
}

.page-actions{
  margin-top:18px;
}

@media (max-width:700px){
  .site-nav{
    width:100%;
    justify-content:flex-start;
  }
}
.simple-page{
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

.simple-main{
  flex:1;
  display:flex;
  justify-content:center;
  align-items:flex-start;
  padding:30px 0 50px;
}

.simple-card{
  width:min(100%, 980px);
  padding:32px;
}

.simple-card h2{
  margin-bottom:16px;
  font-size:clamp(2rem, 4vw, 2.8rem);
}

.simple-card p{
  color:var(--muted);
  line-height:1.9;
  font-size:1.05rem;
  margin-bottom:14px;
}

.simple-footer{
  padding:18px 0 28px;
  text-align:center;
  color:var(--muted);
}

@media (max-width: 900px){
  .topbar{
    flex-direction:column;
    align-items:flex-start;
  }

  .site-nav{
    width:100%;
    justify-content:flex-start;
  }

  .simple-main{
    padding:20px 0 36px;
  }

  .simple-card{
    padding:22px;
  }

  .simple-card p{
    font-size:1rem;
  }
}
.site-nav a,
.site-nav a:visited{
  color:var(--text);
  text-decoration:none;
  font-weight:600;
  opacity:.92;
}

.site-nav a:hover,
.site-nav a:focus{
  opacity:1;
  text-decoration:underline;
}
.guide-layout{
  width:100%;
  display:flex;
  flex-direction:column;
  gap:22px;
}

.guide-list{
  padding-left:20px;
  color:var(--muted);
  line-height:1.9;
}

.guide-list li{
  margin-bottom:8px;
}

.simple-main{
  flex:1;
  display:flex;
  justify-content:center;
  align-items:flex-start;
  padding:30px 0 60px;
}

.simple-footer{
  padding:20px 0 30px;
  text-align:center;
  color:var(--muted);
  margin-top:auto;
}
.page-actions{
  margin-top:20px;
}

.page-actions .primary-btn{
  display:inline-block;
}

.simple-card{
  padding:32px;
}
.primary-btn{
  margin-bottom:6px;
}
.theme-toggle{
  margin-left:20px;
  background:rgba(255,255,255,0.05);
  border:1px solid rgba(255,255,255,0.1);
  padding:10px 14px;
  border-radius:10px;
  cursor:pointer;
  font-size:16px;
}
.mini-converter{
  margin-top:16px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.mini-row{
  display:grid;
  grid-template-columns:1fr auto;
  gap:10px;
}

.mini-row:last-of-type{
  grid-template-columns:1fr 1fr 1fr;
}

.mini-result-box{
  padding:14px 16px;
  border-radius:16px;
  background:var(--glass-soft);
  border:1px solid var(--line);
}

.mini-result-box p{
  margin:0;
  color:var(--text);
}

@media (max-width:700px){
  .mini-row,
  .mini-row:last-of-type{
    grid-template-columns:1fr;
  }
}
.category-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(240px, 1fr));
  gap:16px;
}

.category-card{
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:18px;
  border-radius:20px;
  text-decoration:none;
  color:var(--text);
  border:1px solid var(--line);
  transition:.25s ease;
}

.category-card:hover{
  transform:translateY(-3px);
}

.category-card__cta{
  margin-top:auto;
  font-weight:700;
}
/* ===== Mobile and tablet portrait fixes ===== */

img,
svg,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

input,
select,
button,
textarea {
  max-width: 100%;
  font: inherit;
}

a {
  word-break: break-word;
}

h1,
h2,
h3,
p,
li {
  overflow-wrap: anywhere;
}

/* Better card sizing on narrow screens */
@media (max-width: 900px) {
  .shell {
    width: min(100% - 20px, 1180px);
  }

  .simple-main {
    padding: 16px 0 32px;
  }

  .simple-card,
  .glass-card,
  .glass-soft,
  .content-block,
  .page-hero {
    padding: 18px;
    border-radius: 18px;
  }

  .guide-layout {
    gap: 16px;
  }

  .simple-card h1,
  .simple-card h2,
  .page-hero h2 {
    line-height: 1.2;
  }
}

/* Header/nav fixes for mobile + tablet portrait */
@media (max-width: 820px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .brand {
    width: 100%;
  }

  .site-nav {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .site-nav a {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--glass-soft);
    border: 1px solid var(--line);
    text-align: center;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions .ghost-btn,
  .top-actions .primary-btn,
  .theme-toggle {
    width: 100%;
    margin-left: 0;
  }
}

/* Main converter page fixes */
@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .hero-preview,
  .hero-copy {
    width: 100%;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .main-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .converter,
  .chart-box,
  .panel {
    padding: 16px;
  }

  .section-top {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: span 1;
  }

  .value-row {
    grid-template-columns: 1fr;
  }

  .swap-wrap {
    justify-content: flex-start;
    padding-bottom: 0;
  }

  .swap-btn {
    width: 100%;
    height: 52px;
    border-radius: 14px;
  }

  .result-grid,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .action-row {
    flex-direction: column;
  }

  .action-row .ghost-btn,
  .action-row .primary-btn {
    width: 100%;
  }
}

/* Guide pages + category pages */
@media (max-width: 820px) {
  .category-grid {
    grid-template-columns: 1fr;
  }

  .category-card {
    min-height: auto;
    padding: 16px;
  }

  .guide-list {
    padding-left: 18px;
  }

  .page-actions .primary-btn,
  .category-backlink .primary-btn {
    display: block;
    width: 100%;
    text-align: center;
  }
}

/* Very small phones */
@media (max-width: 480px) {
  .logo {
    width: 50px;
    height: 50px;
    border-radius: 14px;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .brand p {
    font-size: 0.85rem;
  }

  .hero-copy h2,
  .simple-card h2,
  .page-hero h2 {
    font-size: 1.6rem;
  }

  .simple-card,
  .glass-card,
  .glass-soft,
  .content-block,
  .page-hero {
    padding: 14px;
  }

  .mini-result-box,
  .result-card,
  .panel,
  .quick-card {
    padding: 14px;
  }

  .chip {
    font-size: 0.9rem;
    padding: 9px 12px;
  }
}
/* ===== Strong mobile fix for homepage/converter ===== */

@media (max-width: 900px) {
  .topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 0;
  }

  .brand {
    width: 100%;
    align-items: center;
  }

  .site-nav {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .site-nav a {
    display: block;
    width: 100%;
    text-align: center;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--glass-soft);
    border: 1px solid var(--line);
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .top-actions > * {
    width: 100%;
    margin-left: 0 !important;
  }

  .hero {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 14px;
    padding: 16px;
  }

  .hero-copy,
  .hero-preview {
    width: 100%;
    min-width: 0;
  }

  .hero-preview {
    padding: 16px;
  }

  .hero-copy h2 {
    font-size: 1.8rem;
    line-height: 1.15;
  }

  .hero-stats {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .main-grid {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 14px;
    margin-top: 14px;
  }

  .workspace,
  .sidebar {
    width: 100%;
    min-width: 0;
  }

  .converter,
  .chart-box,
  .panel {
    padding: 14px;
  }

  .section-top {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 12px;
    align-items: stretch;
  }

  .chips {
    gap: 8px;
    padding-bottom: 6px;
  }

  .chip {
    flex: 0 0 auto;
    font-size: 0.82rem;
    padding: 8px 10px;
  }

  .form-grid {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .field-span-2 {
    grid-column: span 1 !important;
  }

  .value-row {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .swap-wrap {
    justify-content: stretch;
    align-items: stretch;
    padding-bottom: 0;
  }

  .swap-btn {
    width: 100%;
    height: 48px;
    border-radius: 12px;
  }

  .result-grid,
  .quick-grid {
    grid-template-columns: 1fr !important;
  }

  .result-card h2 {
    font-size: 1.6rem;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .action-row > * {
    width: 100%;
  }

  .chart-box {
    height: auto;
    max-height: none;
  }

  .item-list {
    max-height: none;
  }
}

@media (max-width: 600px) {
  .shell {
    width: calc(100% - 16px);
  }

  .logo {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .brand p {
    font-size: 0.82rem;
  }

  .hero,
  .converter,
  .chart-box,
  .panel,
  .simple-card,
  .content-block,
  .page-hero {
    padding: 12px;
  }

  .hero-copy h2,
  .simple-card h2,
  .page-hero h2 {
    font-size: 1.5rem;
  }

  .section-top input,
  .field input,
  .field select {
    padding: 13px 14px;
    font-size: 16px;
  }

  .ghost-btn,
  .primary-btn,
  .swap-btn {
    min-height: 46px;
  }

  .quick-card,
  .result-card,
  .mini-result-box {
    padding: 12px;
  }
}
/* Fix Chart.js height on mobile */
.chart-box {
  position: relative;
  height: 300px;
  max-height: 300px;
  overflow: hidden;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

@media (max-width: 900px) {
  .chart-box {
    height: 260px !important;
    max-height: 260px !important;
  }
}

@media (max-width: 600px) {
  .chart-box {
    height: 220px !important;
    max-height: 220px !important;
  }
}
.currency-search-wrap{
  margin-bottom:10px;
}

.currency-search-wrap[hidden]{
  display:none !important;
}

.currency-search-wrap input{
  width:100%;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.06);
  color:var(--text);
  outline:none;
  font-size:.96rem;
}

body.light .currency-search-wrap input{
  background:rgba(255,255,255,.9);
}

.currency-search-wrap input::placeholder{
  color:var(--muted);
}
/* ===== Fix result/formula cards on mobile ===== */
@media (max-width: 900px) {
  .result-card {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .result-card p,
  .result-card .eyebrow,
  #resultText,
  #formulaText {
    color: var(--muted);
  }

  #resultValue {
    color: var(--text);
  }
}

/* Keep cards from turning too white in light mode on phones */
@media (max-width: 900px) {
  body.light .result-card {
    background: rgba(255, 255, 255, 0.82) !important;
  }
}

/* ===== Fuller landscape usage on phones/tablets ===== */
@media (orientation: landscape) and (max-height: 600px) {
  .shell {
    width: calc(100% - 12px);
    max-width: none;
  }

  .topbar {
    padding: 10px 0 12px;
  }

  .page-content {
    gap: 14px;
    padding: 12px 0 20px;
  }

  .hero {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px;
    padding: 14px;
  }

  .hero-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .main-grid {
    grid-template-columns: minmax(0, 1fr) 320px !important;
    gap: 12px;
    margin-top: 12px;
  }

  .converter,
  .chart-box,
  .panel {
    padding: 12px;
  }

  .result-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px;
  }

  .quick-grid {
    grid-template-columns: 1fr 1fr;
  }

  .chart-box {
    height: 220px !important;
    max-height: 220px !important;
  }
}

/* Extra-tight phones in landscape */
@media (orientation: landscape) and (max-height: 500px) {
  .shell {
    width: calc(100% - 8px);
  }

  .hero-copy h2 {
    font-size: 1.5rem;
  }

  .section-top input,
  .field input,
  .field select {
    padding: 12px 13px;
  }

  .swap-btn {
    height: 44px;
  }

  .chart-box {
    height: 200px !important;
    max-height: 200px !important;
  }
}
#historyControls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

#historyUpdatedLabel {
  font-size: 0.9rem;
  opacity: 0.85;
}

.history-range-btn {
  min-width: 64px;
}

@media (max-width: 700px) {
  #historyControls {
    gap: 6px;
  }

  #historyUpdatedLabel {
    width: 100%;
    margin-left: 0 !important;
  }
}
/* ===== FIX 1: Dark mode result/formula cards on mobile ===== */
.result-card {
  background: var(--glass-soft);
  border: 1px solid var(--line);
  color: var(--text);
}

.result-card p,
.result-card .eyebrow,
#resultText,
#formulaText,
#featuredText {
  color: var(--muted);
}

#resultValue {
  color: var(--text);
}

body:not(.light) .result-card {
  background: rgba(255, 255, 255, 0.06) !important;
  color: var(--text) !important;
}

body:not(.light) .result-card p,
body:not(.light) #resultText,
body:not(.light) #formulaText,
body:not(.light) #featuredText,
body:not(.light) .result-card .eyebrow {
  color: rgba(237, 244, 255, 0.82) !important;
}

body:not(.light) #resultValue {
  color: #edf4ff !important;
}

/* ===== FIX 2: Ensure chart is visible on mobile ===== */
.chart-box {
  position: relative;
  min-height: 260px;
  height: 260px;
  max-height: 260px;
  overflow: hidden;
}

.chart-box canvas,
#resultChart {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
}

@media (max-width: 700px) {
  .chart-box {
    min-height: 240px;
    height: 240px;
    max-height: 240px;
  }
}

@media (max-width: 480px) {
  .chart-box {
    min-height: 220px;
    height: 220px;
    max-height: 220px;
  }
}

/* ===== FIX 3: Mobile portrait layout cleanup ===== */
@media (max-width: 820px) {
  .shell {
    width: calc(100% - 16px);
    max-width: none;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 0;
  }

  .brand {
    width: 100%;
  }

  .site-nav {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .site-nav a {
    display: block;
    width: 100%;
    text-align: center;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--glass-soft);
    border: 1px solid var(--line);
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .top-actions > * {
    width: 100%;
    margin-left: 0 !important;
  }

  .hero,
  .main-grid,
  .result-grid,
  .quick-grid,
  .section-top,
  .form-grid,
  .value-row {
    grid-template-columns: 1fr !important;
  }

  .converter,
  .panel,
  .chart-box,
  .simple-card,
  .content-block,
  .page-hero {
    padding: 14px;
  }

  .swap-wrap {
    justify-content: stretch;
  }

  .swap-btn {
    width: 100%;
    height: 48px;
    border-radius: 12px;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .action-row > * {
    width: 100%;
  }
}

/* ===== FIX 4: Landscape mobile should use full width ===== */
@media (orientation: landscape) and (max-height: 600px) {
  .shell {
    width: calc(100% - 8px);
    max-width: none;
  }

  .simple-main,
  .page-content {
    padding-left: 0;
    padding-right: 0;
  }

  .topbar {
    padding: 8px 0 10px;
  }

  .site-nav {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .hero {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px;
  }

  .hero-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .main-grid {
    grid-template-columns: minmax(0, 1fr) 320px !important;
    gap: 12px;
  }

  .result-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px;
  }

  .quick-grid {
    grid-template-columns: 1fr 1fr;
  }

  .converter,
  .panel,
  .chart-box {
    padding: 12px;
  }

  .chart-box {
    min-height: 200px;
    height: 200px;
    max-height: 200px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .shell {
    width: calc(100% - 4px);
  }

  .site-nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .hero-copy h2,
  .simple-card h2,
  .page-hero h2 {
    font-size: 1.5rem;
  }

  .chart-box {
    min-height: 180px;
    height: 180px;
    max-height: 180px;
  }
}

/* ===== JamasaLabs live hotfixes: dark mobile cards, chart visibility, landscape width ===== */
body:not(.light) article.result-card.glass-soft,
body:not(.light) .result-grid .result-card.glass-soft,
body:not(.light) .result-grid .result-card {
  background: rgba(18, 28, 48, 0.94) !important;
  background-image: none !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

body:not(.light) article.result-card.glass-soft *,
body:not(.light) .result-grid .result-card * {
  color: inherit;
}

body:not(.light) .result-grid .result-card .eyebrow,
body:not(.light) .result-grid .result-card p,
body:not(.light) #resultText,
body:not(.light) #formulaText,
body:not(.light) #featuredText {
  color: rgba(237,244,255,.84) !important;
}

body:not(.light) .result-grid .result-card h2,
body:not(.light) #resultValue {
  color: #edf4ff !important;
}

body:not(.light) .result-grid .result-card .ghost-btn {
  background: rgba(255,255,255,.08) !important;
  color: #edf4ff !important;
  border: 1px solid rgba(255,255,255,.12) !important;
}

body:not(.light) .result-grid .result-card .ghost-btn:hover {
  background: rgba(255,255,255,.12) !important;
}

/* more robust chart area sizing */
.chart-box,
section.chart-box.glass-card {
  position: relative;
  min-height: 300px;
  height: 300px;
  max-height: 300px;
  overflow: hidden;
}

#resultChart,
.chart-box canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
}

@media (max-width: 820px) {
  .chart-box,
  section.chart-box.glass-card {
    min-height: 260px !important;
    height: 260px !important;
    max-height: 260px !important;
  }

  .result-grid {
    grid-template-columns: 1fr !important;
  }

  .result-grid .result-card {
    padding: 18px !important;
  }

  .result-grid .action-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .result-grid .action-row .ghost-btn,
  .result-grid .action-row .primary-btn {
    width: 100% !important;
  }
}

@media (max-width: 560px) {
  .shell { width: calc(100% - 14px) !important; }

  .chart-box,
  section.chart-box.glass-card {
    min-height: 240px !important;
    height: 240px !important;
    max-height: 240px !important;
  }

  #historyControls {
    gap: 8px;
  }

  #historyControls .history-range-btn,
  #historyControls .primary-btn,
  #historyControls .ghost-btn {
    min-width: 0;
    flex: 1 1 calc(33.333% - 8px);
    justify-content: center;
  }
}

/* landscape phones/tablets should use much more width */
@media (orientation: landscape) and (max-width: 1400px) {
  .shell {
    width: calc(100% - 8px) !important;
    max-width: none !important;
  }

  .topbar {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (orientation: landscape) and (max-width: 1100px) {
  .topbar {
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px;
  }

  .site-nav {
    width: auto !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
  }

  .site-nav a {
    width: auto !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
  }

  .main-grid {
    grid-template-columns: minmax(0,1fr) 320px !important;
    gap: 12px !important;
  }

  .hero {
    grid-template-columns: 1fr 1fr !important;
  }

  .quick-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .chart-box,
  section.chart-box.glass-card {
    min-height: 220px !important;
    height: 220px !important;
    max-height: 220px !important;
  }
}

@media (orientation: landscape) and (max-width: 900px) {
  .main-grid,
  .result-grid,
  .quick-grid,
  .section-top,
  .form-grid,
  .value-row {
    grid-template-columns: 1fr !important;
  }

  .site-nav {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .site-nav a {
    width: 100% !important;
  }

  .chart-box,
  section.chart-box.glass-card {
    min-height: 200px !important;
    height: 200px !important;
    max-height: 200px !important;
  }
}
