/* Shared mobile shell for cryptography and hash tools. Desktop layout is intentionally untouched. */
.crypto-mobile-header,
.crypto-mobile-nav {
  display: none;
}
.calculator-mobile-unit-toggle {
  display: none;
}

@media (max-width: 720px) {
  :root { --crypto-mobile-nav-height: 67px; }

  body[data-crypto-mobile-template] {
    padding-bottom: calc(var(--crypto-mobile-nav-height) + env(safe-area-inset-bottom, 0px));
    background: #f7f9fc;
  }

  body[data-crypto-mobile-template] .wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100dvh;
    padding-top: 0;
    background: #f7f9fc;
  }
  body[data-crypto-mobile-template] .wrap > funify-header {
    display: block !important;
    flex: 0 0 auto;
    width: 100%;
  }
  body[data-crypto-mobile-template] .repo-hero { display: none; }

  .crypto-mobile-header {
    position: sticky;
    top: 0;
    z-index: 70;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
    min-height: 52px;
    box-sizing: border-box;
    padding: 0 12px;
    border-bottom: 1px solid #e7edf5;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 8px 18px rgba(16, 24, 40, .04);
    backdrop-filter: blur(16px);
  }

  .crypto-mobile-header::after { content: ""; width: 34px; height: 34px; }
  .crypto-mobile-back {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #1d2939;
  }
  .crypto-mobile-back::before {
    content: "";
    width: 10px;
    height: 10px;
    margin-left: 4px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    border-radius: 1px;
    transform: rotate(45deg);
  }
  body.mobile-crypto-section-calculator .crypto-mobile-back { visibility: hidden; }
  .crypto-mobile-title {
    overflow: hidden;
    color: #101828;
    font: 800 18px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    letter-spacing: -.02em;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.mobile-crypto-section-calculator .crypto-mobile-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    overflow: visible;
    font-size: 18px;
    line-height: 24px;
  }
  body.mobile-crypto-section-calculator .crypto-mobile-title::before {
    content: "\1F512";
    flex: 0 0 auto;
    display: block;
    width: 20px;
    height: 24px;
    margin: 0;
    font-size: 17px;
    font-weight: 400;
    line-height: 24px;
    text-align: center;
  }
  body[data-calculator-mobile-template].mobile-crypto-section-calculator .crypto-mobile-title::before {
    content: "\1F9EE";
  }
  body[data-calculator-mobile-template].mobile-crypto-section-calculator .crypto-mobile-title[data-mobile-tool-icon]::before {
    content: attr(data-mobile-tool-icon);
  }

  body[data-crypto-mobile-template] .calculator-page {
    width: 100%;
    margin: 0;
    padding: 14px 10px 18px;
    box-sizing: border-box;
  }
  body[data-crypto-mobile-template] .calculator-grid { display: block; }
  body[data-crypto-mobile-template] .calculator-main { min-width: 0; }
  body[data-crypto-mobile-template] .calculator-panel,
  body[data-crypto-mobile-template] .calculator-guide-section,
  body[data-crypto-mobile-template] .calculator-related-section {
    border-color: #dbe7f5;
    border-radius: 16px;
    box-shadow: 0 8px 22px rgba(30, 55, 90, .07);
  }
  body[data-calculator-mobile-template].mobile-crypto-section-calculator #calculator {
    display: flex !important;
    flex-direction: column;
    min-height: max(360px, calc(100dvh - 204px - env(safe-area-inset-bottom, 0px)));
    box-sizing: border-box;
  }
  body[data-calculator-mobile-template] .calculator-mobile-empty-state {
    display: grid;
    flex: 1 1 auto;
    place-items: center;
    align-content: center;
    min-height: 150px;
    margin-top: 14px;
    padding: 24px 16px;
    box-sizing: border-box;
    border: 1px dashed #cbd8e8;
    border-radius: 14px;
    background: color-mix(in srgb, #f7f9fc 84%, #fff 16%);
    color: #667085;
    text-align: center;
  }
  body[data-calculator-mobile-template] .calculator-mobile-empty-state[hidden] { display: none !important; }
  body[data-calculator-mobile-template] .calculator-mobile-empty-state strong {
    margin-top: 5px;
    color: #344054;
    font-size: 14px;
  }
  body[data-calculator-mobile-template] .calculator-mobile-empty-state p {
    max-width: 260px;
    margin: 6px 0 0;
    color: #667085;
    font-size: 12px;
    line-height: 1.55;
  }
  .calculator-mobile-empty-icon {
    color: #2f80ed;
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
  }

  body[data-crypto-mobile-template] [data-crypto-mobile-panel],
  body[data-crypto-mobile-template] .calculator-aside { display: none !important; }
  body.mobile-crypto-section-calculator [data-crypto-mobile-panel="calculator"],
  body.mobile-crypto-section-overview [data-crypto-mobile-panel="overview"],
  body.mobile-crypto-section-howto [data-crypto-mobile-panel="howto"],
  body.mobile-crypto-section-guide [data-crypto-mobile-panel="guide"],
  body.mobile-crypto-section-faq [data-crypto-mobile-panel="faq"] { display: block !important; }
  body[data-crypto-mobile-template] [data-tool-mobile-extra] { display: none !important; }
  body[data-crypto-mobile-template] #howto { margin-top: 0; }

  body.mobile-crypto-section-faq .calculator-aside {
    display: block !important;
    margin-top: 12px;
  }
  body.mobile-crypto-section-faq .calculator-aside > :not([data-crypto-mobile-related]) { display: none !important; }
  body.mobile-crypto-section-faq [data-crypto-mobile-related] { display: block !important; }
  body.mobile-crypto-section-faq [data-crypto-mobile-related] .calculator-related-grid { grid-template-columns: 1fr; }

  body[data-crypto-mobile-template] .calculator-panel-head { align-items: center; }
  body[data-crypto-mobile-template] .calculator-guide-body { min-width: 0; }
  body[data-crypto-mobile-template] .calculator-guide-body img,
  body[data-crypto-mobile-template] .calculator-guide-body table { max-width: 100%; }
  body[data-crypto-mobile-template] .calculator-table-wrap { overflow-x: auto; }
  body[data-crypto-mobile-template] #calculator > .calculator-note { display: none !important; }
  body[data-calculator-mobile-template] #calculator .calculator-result-toolbar {
    display: flex;
    align-items: baseline;
    gap: 8px;
  }
  body[data-calculator-mobile-template] #calculator .calculator-result-toolbar .calculator-status {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
  }
  body[data-calculator-mobile-template] #calculator .calculator-result-toolbar > .calculator-unit-toggle {
    display: none !important;
  }
  body[data-calculator-mobile-template] #calculator .calculator-mobile-unit-toggle {
    display: inline;
    flex: 0 0 auto;
    margin-left: auto;
    color: var(--brand);
    font-size: .92rem;
    font-weight: 800;
    line-height: 1.3;
    cursor: pointer;
    white-space: nowrap;
  }
  body[data-calculator-mobile-template] #calculator .calculator-mobile-unit-toggle:focus-visible {
    border-radius: 4px;
    outline: 2px solid var(--brand);
    outline-offset: 3px;
  }
  body[data-crypto-mobile-template] .calculator-action-buttons > #decryptBtn { order: 1; }
  body[data-crypto-mobile-template] .calculator-action-buttons > #encryptBtn { order: 2; }
  body[data-calculator-mobile-template] #calculator .calculator-button-row[aria-label="Result actions"] {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
  }
  body[data-calculator-mobile-template] #calculator .calculator-button-row[aria-label="Result actions"] .calculator-notes-link {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
  }
  body[data-calculator-mobile-template] #calculator section[aria-labelledby="scenarioTitle"] > .calculator-button-row {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
    width: 100%;
  }
  body[data-calculator-mobile-template] #calculator section[aria-labelledby="scenarioTitle"] > .calculator-button-row > button {
    width: 100%;
    min-width: 0;
    margin: 0;
    white-space: nowrap;
  }

  /* Keep every tool's settings drawer fully scrollable on short mobile viewports. */
  body[data-crypto-mobile-template] [class$="-workspace-drawer-panel"] {
    height: 100% !important;
    min-height: 0;
    box-sizing: border-box;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
  }
  body[data-crypto-mobile-template].modal-open .crypto-mobile-nav {
    display: none !important;
  }

  .crypto-mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    border-top: 1px solid #e3ebf5;
    border-radius: 18px 18px 0 0;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 -12px 28px rgba(16, 24, 40, .08);
    backdrop-filter: blur(18px);
  }
  .crypto-mobile-nav button {
    display: grid;
    grid-template-rows: 24px 14px;
    justify-items: center;
    align-content: center;
    gap: 3px;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: #667085;
    font: 800 9px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    cursor: pointer;
  }
  .crypto-mobile-nav button > span:last-child { line-height: 14px; white-space: nowrap; }
  .crypto-mobile-nav-icon {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
  }
  .crypto-mobile-nav-icon svg { display: block; width: 22px; height: 22px; }
  .crypto-mobile-nav button.active { color: #0f67d8; }
  .crypto-mobile-nav button.active .crypto-mobile-nav-icon {
    background: #0f67d8;
    color: #fff;
    box-shadow: 0 8px 16px rgba(15, 103, 216, .20);
  }

  body[data-crypto-mobile-template] .wrap > funify-footer {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    margin-bottom: 0 !important;
    padding: 0 4px;
    box-sizing: border-box;
  }

  html[data-theme="dark"],
  html[data-theme="dark"] body[data-crypto-mobile-template],
  html[data-theme="dark"] body[data-crypto-mobile-template] .wrap,
  html[data-theme="dark"] body[data-crypto-mobile-template] .wrap > funify-footer,
  html[data-theme="dark"] body[data-crypto-mobile-template] .wrap > funify-footer .footer {
    background: #0d1117 !important;
  }
  html[data-theme="dark"] .crypto-mobile-header {
    border-bottom-color: #30363d;
    background: rgba(13, 17, 23, .96);
    box-shadow: 0 8px 18px rgba(0, 0, 0, .22);
  }
  html[data-theme="dark"] .crypto-mobile-title,
  html[data-theme="dark"] .crypto-mobile-back {
    color: #f0f6fc;
  }
  html[data-theme="dark"] .crypto-mobile-back:active { background: #21262d; }
  html[data-theme="dark"] body[data-crypto-mobile-template] .calculator-panel,
  html[data-theme="dark"] body[data-crypto-mobile-template] .calculator-guide-section,
  html[data-theme="dark"] body[data-crypto-mobile-template] .calculator-related-section {
    border-color: #30363d;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .22);
  }
  html[data-theme="dark"] body[data-calculator-mobile-template] .calculator-mobile-empty-state {
    border-color: #30363d;
    background: #161b22;
    color: #8b949e;
  }
  html[data-theme="dark"] body[data-calculator-mobile-template] .calculator-mobile-empty-state strong {
    color: #f0f6fc;
  }
  html[data-theme="dark"] body[data-calculator-mobile-template] .calculator-mobile-empty-state p {
    color: #8b949e;
  }
  html[data-theme="dark"] .crypto-mobile-nav {
    border-top-color: #30363d;
    background: rgba(13, 17, 23, .96);
    box-shadow: 0 -12px 28px rgba(0, 0, 0, .28);
  }
  html[data-theme="dark"] .crypto-mobile-nav button { color: #8b949e; }
  html[data-theme="dark"] .crypto-mobile-nav button.active { color: #58a6ff; }
  html[data-theme="dark"] .crypto-mobile-nav button.active .crypto-mobile-nav-icon {
    background: #1f6feb;
    color: #fff;
    box-shadow: 0 8px 16px rgba(31, 111, 235, .28);
  }
}
