@font-face{font-family:Harabara;src:url('../harabara.ttf') format('truetype');font-display:swap}
:root{--bg:#f4f7fb;--surface:#fff;--surface2:#f8fafc;--text:#0f172a;--muted:#64748b;--line:#dbe3ee;--brand:#078fd0;--brand2:#006da5;--accent:#f5b800;--shadow:0 8px 30px rgba(15,23,42,.08);--top:#0f172a}
:root[data-theme=dark]{--bg:#0b1220;--surface:#111827;--surface2:#172033;--text:#f8fafc;--muted:#a9b6c8;--line:#2b3950;--brand:#35b7ef;--brand2:#75cff7;--accent:#ffd45a;--shadow:0 10px 35px rgba(0,0,0,.25);--top:#090f1b}
*{box-sizing:border-box}html,body{margin:0;min-height:100%;font-family:'Noto Sans Gujarati',system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;background:var(--bg);color:var(--text)}button,input{font:inherit}button{cursor:pointer}.app{min-height:100vh;height:100dvh;display:flex;flex-direction:column;overflow:hidden}
.topbar{position:sticky;top:0;z-index:50;background:rgba(15,23,42,.97);color:#fff;border-bottom:1px solid #263247;backdrop-filter:blur(12px)}.topbar-inner{width:min(1500px,100%);margin:auto;padding:11px 18px;display:flex;align-items:center;gap:12px}.brand{display:flex;align-items:center;gap:10px;min-width:0}.brand img{width:40px;height:40px;object-fit:contain}.brand-text{line-height:1.05}.brand-title{font-family:Harabara,sans-serif;font-size:19px;letter-spacing:.5px}.brand-sub{font-size:11px;color:#cbd5e1;margin-top:4px}.top-actions{margin-left:auto;display:flex;align-items:center;gap:8px}.top-btn,.menu-btn{border:1px solid #475569;background:#1e293b;color:#fff;border-radius:10px;padding:8px 11px}.install-btn{background:var(--accent);border-color:var(--accent);color:#111827;font-weight:800}.menu-btn{display:none;font-size:20px;line-height:1;padding:7px 10px}
.layout{width:min(1500px,100%);margin:auto;display:grid;grid-template-columns:minmax(0,1fr) 310px;gap:18px;padding:22px 18px 20px;flex:1;min-height:0;overflow:auto;align-items:start}.main{min-width:0}.hero{margin:0 0 14px 2px}.hero h1{font-size:clamp(22px,4vw,32px);margin:0}
.panel{background:var(--surface);border:1px solid var(--line);border-radius:18px;box-shadow:var(--shadow)}.converter{padding:18px}.converter-head{margin-bottom:14px}.results-title{font-size:19px;font-weight:850}
.results{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:11px}.result-card{min-width:0;border:1px solid var(--line);background:var(--surface2);border-radius:14px;padding:11px;transition:border-color .15s,box-shadow .15s,transform .15s}.result-card.selected{border-color:var(--brand);box-shadow:inset 0 0 0 1px var(--brand),0 4px 14px rgba(7,143,208,.08)}.result-card:hover{transform:translateY(-1px)}.result-label{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px;min-width:0}.result-gu{font-size:14px;font-weight:850;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.result-en{color:var(--muted);font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.result-input-row{display:flex;gap:7px;align-items:center}.result-input{width:100%;min-width:0;border:1.5px solid var(--line);border-radius:10px;background:var(--surface);color:var(--text);font-size:20px;font-weight:800;text-align:right;padding:10px 11px;outline:none}.result-input:focus{border-color:var(--brand);box-shadow:0 0 0 3px rgba(7,143,208,.12)}.copy-btn{flex:0 0 38px;border:1px solid var(--line);background:var(--surface);color:var(--muted);height:42px;border-radius:10px}.copy-btn:hover{color:var(--brand);border-color:var(--brand)}
.history-panel{position:sticky;top:0;background:var(--surface);border:1px solid var(--line);border-radius:18px;box-shadow:var(--shadow);overflow:hidden;height:100%;max-height:none;min-height:0;display:flex;flex-direction:column}.history-head{padding:16px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:8px}.history-title{font-size:18px;font-weight:850}.history-sub{font-size:11px;color:var(--muted);margin-top:2px}.history-clear{margin-left:auto;border:1px solid var(--line);background:var(--surface2);color:var(--muted);border-radius:8px;padding:6px 8px;font-size:11px}.history-close{display:none;border:0;background:transparent;color:var(--text);font-size:24px;padding:2px 5px}.history-list{overflow:auto;padding:9px;min-height:0;flex:1}.history-item{border-bottom:1px solid var(--line);padding:10px 6px;margin:0}.history-item:last-child{border-bottom:0}.history-value{font-weight:850;font-size:16px}.history-unit{font-size:12px;color:var(--muted);margin-top:2px}.history-time{font-size:10px;color:var(--muted);margin-top:5px}.empty-history{padding:30px 18px;color:var(--muted);font-size:12px;text-align:center}
.footer{color:#fff;font-size:13px;background:#1e293b;padding:10px 0;border-top:1px solid #334155;width:100%;flex-shrink:0;text-align:center}.footer img{height:26px;width:auto;vertical-align:middle;margin-right:2px}.brand-font{font-family:Harabara,sans-serif;font-size:14px}.color-ark{color:#0098db}.color-associate{color:#96989b}
.toast{position:fixed;left:50%;bottom:24px;transform:translate(-50%,20px);background:#0f172a;color:#fff;padding:10px 15px;border-radius:999px;opacity:0;pointer-events:none;transition:.2s;z-index:100}.toast.show{opacity:1;transform:translate(-50%,0)}
.history-backdrop{display:none}.modal{display:none;position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:80;align-items:center;justify-content:center;padding:20px}.modal.show{display:flex}.modal-card{width:min(420px,100%);background:var(--surface);color:var(--text);border-radius:18px;padding:20px;box-shadow:0 20px 60px rgba(0,0,0,.3)}.modal-card img{width:50px;height:50px}.modal-head{display:flex;justify-content:space-between;align-items:center}.modal-close{border:0;background:transparent;color:var(--text);font-size:22px}.modal-card ol{padding-left:20px;color:var(--muted);line-height:1.7}
@media(max-width:1100px){.results{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:900px){.layout{grid-template-columns:1fr;padding:16px 12px 20px}.history-panel{position:fixed;z-index:70;top:0;right:0;bottom:0;width:min(340px,88vw);height:auto;max-height:none;border-radius:18px 0 0 18px;transform:translateX(105%);transition:transform .22s ease}.history-panel.open{transform:translateX(0)}.history-close{display:block}.history-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:60;opacity:0;pointer-events:none;display:block;transition:opacity .22s}.history-backdrop.open{opacity:1;pointer-events:auto}.menu-btn{display:block}.hero{margin-left:0}}
@media(max-width:620px){.topbar-inner{padding:8px 10px}.brand img{width:34px;height:34px}.brand-title{font-size:16px}.brand-sub{font-size:9px}.top-actions{gap:5px}.top-btn{padding:7px 8px;font-size:12px}.layout{padding:11px 8px 18px}.hero{margin:4px 3px 11px}.hero h1{font-size:23px}.converter{padding:11px;border-radius:14px}.results{grid-template-columns:1fr;gap:8px}.result-card{padding:10px}.result-input{font-size:19px;padding:9px 10px}.footer{padding:10px 8px}.history-head{padding:14px}}

/* v5 mobile/history fixes */
.history-item{cursor:pointer;border-radius:10px;transition:background .15s,transform .15s;padding:11px 8px}
.history-item:hover,.history-item:focus{background:var(--surface2);outline:none}
.history-item:active{transform:scale(.99)}
@media(max-width:900px){
  html,body{width:100%;overflow-x:hidden}
  .app{width:100%;min-height:100dvh}
  .topbar{position:sticky;top:0}
  .topbar-inner{width:100%;min-width:0}
  .layout{width:100%;display:block}
  .main{width:100%;min-width:0}
  .converter{width:100%;max-width:none}
  .results{width:100%}
  .result-card{width:100%;touch-action:manipulation}
  .result-input{min-height:44px;touch-action:manipulation;-webkit-appearance:none}
  .menu-btn{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto}
  .brand{flex:1;min-width:0}
  .top-actions{flex:0 0 auto}
}
@media(max-width:620px){
  .topbar-inner{gap:7px}
  .brand{gap:7px}
  .brand img{width:32px;height:32px}
  .brand-title{font-size:15px}
  .brand-sub{display:none}
  .top-btn{min-width:38px;min-height:38px;padding:7px}
  .menu-btn{min-width:40px;min-height:40px}
  .layout{padding:9px 7px 14px}
  .hero h1{font-size:21px}
  .converter{padding:9px}
  .results{gap:7px}
  .result-card{padding:9px;border-radius:12px}
  .result-label{margin-bottom:6px}
  .result-input{font-size:18px;min-height:44px;padding:9px}
  .copy-btn{min-height:44px}
  .history-panel{width:min(340px,92vw)}
  .footer{font-size:12px}
}

@media(max-width:900px){
  .topbar-inner .brand{order:1}
  .topbar-inner .top-actions{order:2;margin-left:auto}
  .topbar-inner .menu-btn{order:3}
}


/* v6.4 mobile compact two-column layout */
@media (max-width: 600px) {
  .app {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .layout {
    display: block;
    width: 100%;
    padding: 12px 10px 12px;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .units-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .unit-card {
    min-width: 0;
  }

  .unit-card input {
    min-width: 0;
    width: 100%;
  }

  /* History remains a right-side drawer on mobile. */
  .history-panel {
    height: 100dvh;
    max-height: 100dvh;
  }

  /* Footer stays visible at the bottom rather than requiring page scroll. */
  footer,
  .footer {
    flex: 0 0 auto;
    position: relative;
    z-index: 5;
  }
}

/* Very narrow phones: still keep two columns, but reduce spacing. */
@media (max-width: 380px) {
  .layout {
    padding-left: 7px;
    padding-right: 7px;
  }

  .units-grid {
    gap: 7px !important;
  }

  .unit-card {
    padding: 10px !important;
  }
}


/* Mobile: keep the normal unit cards, but use 2 columns (desktop uses 3). */
@media (max-width: 600px) {
  .units-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .unit-card {
    min-width: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 12px !important;
    display: block !important;
  }

  .unit-card .unit-title,
  .unit-card .unit-name,
  .unit-card .label {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-size: inherit !important;
  }

  .unit-card input {
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 40px !important;
    font-size: 16px !important;
  }

  .unit-card .copy-btn,
  .unit-card button {
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
  }
}

@media (max-width: 380px) {
  .units-grid {
    gap: 7px !important;
  }

  .unit-card {
    padding: 10px !important;
  }
}


/* v6.4.2: force exactly 2 unit cards per row on mobile */
@media screen and (max-width: 600px) {
  .units-grid,
  #unitsGrid,
  .unit-grid,
  .conversion-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important;
    width: 100% !important;
    gap: 10px !important;
  }

  .units-grid > *,
  #unitsGrid > *,
  .unit-grid > *,
  .conversion-grid > * {
    width: auto !important;
    max-width: none !important;
    grid-column: auto !important;
  }
}

@media screen and (max-width: 380px) {
  .units-grid,
  #unitsGrid,
  .unit-grid,
  .conversion-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
  }
}

/* v6.6.1 mobile/PWA final fixes */
@media screen and (max-width: 620px) {
  .brand-sub {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: 9px !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
  }

  .results {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important;
    gap: 8px !important;
  }

  .result-card {
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
  }

  .layout {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    overflow-y: auto !important;
    padding-bottom: 12px !important;
  }

  .footer {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    min-height: 46px !important;
    z-index: 5 !important;
  }
}

@media screen and (max-width: 360px) {
  .results {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  .result-card { padding: 7px !important; }
  .result-gu { font-size: 12px !important; }
  .result-en { font-size: 9px !important; }
  .result-input { font-size: 16px !important; padding: 8px !important; }
  .copy-btn { flex-basis: 34px !important; height: 40px !important; }
}

/* =========================================================
   FINAL MOBILE FIX
   1. Unit/result cards = SINGLE COLUMN on mobile
   2. Content scrolls inside the available screen area
   3. Footer stays fixed at bottom of the app viewport
   ========================================================= */

/* Mobile and mobile/PWA */
@media screen and (max-width: 620px) {

  /* Keep the app exactly the height of the device screen */
  .app {
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* Header stays at top */
  .topbar {
    flex: 0 0 auto !important;
    position: relative !important;
    top: auto !important;
  }

  /* Main area takes remaining screen space and scrolls */
  .layout {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    display: block !important;

    width: 100% !important;
    padding: 10px 8px 14px !important;

    -webkit-overflow-scrolling: touch;
  }

  .main {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* =====================================================
     SINGLE COLUMN
     ===================================================== */

  .results,
  .units-grid,
  #unitsGrid,
  .unit-grid,
  .conversion-grid {
    display: grid !important;

    /* ONE card per row */
    grid-template-columns: minmax(0, 1fr) !important;

    grid-auto-flow: row !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .result-card,
  .unit-card,
  .units-grid > *,
  #unitsGrid > *,
  .unit-grid > *,
  .conversion-grid > * {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    grid-column: auto !important;
  }

  /* Normal card sizing */
  .result-card,
  .unit-card {
    padding: 10px !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .result-input,
  .unit-card input {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
  }

  /* =====================================================
     FOOTER
     ===================================================== */

  .footer,
  footer {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;

    /* Footer occupies its own fixed-height area */
    flex: 0 0 auto !important;
    width: 100% !important;

    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;

    min-height: 46px !important;
    padding: 10px 8px !important;

    z-index: 20 !important;
  }
}


/* =========================================================
   VERY SMALL PHONES
   Still SINGLE COLUMN
   ========================================================= */

@media screen and (max-width: 380px) {

  .layout {
    padding-left: 7px !important;
    padding-right: 7px !important;
  }

  .results,
  .units-grid,
  #unitsGrid,
  .unit-grid,
  .conversion-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 7px !important;
  }

  .result-card,
  .unit-card {
    padding: 9px !important;
  }
}