/* Desktop floating calculator — compact calc-mode panel (web @1024px+ only). */

@media (min-width: 1024px) {
  .header-desktop-calc-btn {
    display: none;
  }

  body.desktop-side-menu-mode .header-desktop-calc-btn {
    display: inline-flex;
  }

  .desktop-floating-calc {
    --dfc-width: 320px;
    position: fixed;
    z-index: 1250;
    width: var(--dfc-width);
    max-width: calc(100vw - 2rem);
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: none;
    user-select: none;
  }

  body.light-theme .desktop-floating-calc {
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
  }

  .desktop-floating-calc.hidden {
    display: none;
  }

  .desktop-floating-calc.is-open {
    display: flex;
  }

  .desktop-floating-calc__chrome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.5rem 0.45rem 0.65rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
    cursor: grab;
    flex-shrink: 0;
  }

  .desktop-floating-calc__chrome:active {
    cursor: grabbing;
  }

  .desktop-floating-calc__title {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary, var(--ink3));
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    pointer-events: none;
  }

  .desktop-floating-calc__title i {
    font-size: 0.9rem;
    opacity: 0.85;
  }

  .desktop-floating-calc__actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    flex-shrink: 0;
  }

  .desktop-floating-calc__icon-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary, var(--ink2));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
  }

  .desktop-floating-calc__icon-btn:hover {
    background: var(--surface2, rgba(255, 255, 255, 0.08));
    color: var(--text-primary, var(--ink));
  }

  .desktop-floating-calc__body {
    padding: 0 10px 12px;
    overflow: auto;
    max-height: min(78vh, 640px);
    -webkit-overflow-scrolling: touch;
  }

  .desktop-floating-calc .calc-mode {
    padding: 8px 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .desktop-floating-calc .calc-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 4px 0;
  }

  .desktop-floating-calc .calc-controls-bar .calc-round-bar {
    flex: 1;
    margin-bottom: 0;
  }

  .desktop-floating-calc .calc-round-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
  }

  .desktop-floating-calc .calc-round-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink3);
  }

  .desktop-floating-calc .calc-round-control {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 2px 4px;
  }

  .desktop-floating-calc .calc-round-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    color: var(--ink2);
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
  }

  .desktop-floating-calc .calc-round-chevron svg {
    width: 12px;
    height: 12px;
  }

  .desktop-floating-calc .calc-round-value {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--ink);
    min-width: 40px;
    text-align: center;
  }

  .desktop-floating-calc .calc-display-wrap {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: 12px 14px;
    min-height: 88px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 6px;
  }

  .desktop-floating-calc .calc-expression {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--ink3);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
    min-height: 1.1em;
  }

  .desktop-floating-calc .calc-result {
    font-family: var(--mono);
    font-size: 1.85rem;
    font-weight: 500;
    color: var(--ink);
    text-align: right;
    white-space: nowrap;
    overflow-x: auto;
    width: 100%;
    scrollbar-width: none;
  }

  .desktop-floating-calc .calc-result::-webkit-scrollbar {
    display: none;
  }

  .desktop-floating-calc .frac-display {
    display: inline-flex;
    flex-direction: column;
    vertical-align: middle;
    font-size: 0.65em;
    line-height: 0.9;
    text-align: center;
    margin: 0 2px;
  }

  .desktop-floating-calc .frac-display sup {
    border-bottom: 1px solid currentColor;
    padding-bottom: 2px;
    margin-bottom: 1px;
  }

  .desktop-floating-calc .calc-history-bar,
  .desktop-floating-calc .calc-history,
  .desktop-floating-calc .calc-history-modal-btn {
    display: none !important;
  }

  .desktop-floating-calc .calc-pad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    overflow: hidden;
  }

  .desktop-floating-calc .calc-display-toggle {
    grid-column: 1 / -1;
    display: flex;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    padding: 2px;
    gap: 2px;
  }

  .desktop-floating-calc .calc-toggle-opt {
    flex: 1;
    padding: 7px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink2);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
  }

  .desktop-floating-calc .calc-toggle-opt.active {
    background: var(--accent);
    color: var(--accent-fg);
  }

  .desktop-floating-calc .calc-key {
    border-radius: 0;
    font-size: 1.05rem;
    font-weight: 500;
    background: var(--bg-card);
    color: var(--ink);
    height: 48px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .desktop-floating-calc .calc-key.calc-op {
    background: var(--accent);
    color: var(--accent-fg);
  }

  .desktop-floating-calc .calc-key.calc-func {
    background: var(--surface2);
    color: var(--ink2);
  }

  .desktop-floating-calc .calc-key.calc-equals {
    background: var(--green);
    color: var(--accent-fg);
  }

  .desktop-floating-calc .calc-frac-picker {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    margin-top: -4px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.25s, opacity 0.25s;
  }

  .desktop-floating-calc .calc-frac-picker:not(.hidden) {
    max-height: 420px;
    opacity: 1;
    margin-top: 0;
  }

  .desktop-floating-calc .calc-frac-picker.modal-open:not(.hidden) {
    position: fixed;
    z-index: 1300;
    max-width: calc(100vw - 24px);
    max-height: min(48vh, 340px);
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: var(--elev-shadow);
    transition: none;
  }

  .desktop-floating-calc.ws-frac-modal-open .calc-mode {
    overflow-y: hidden;
  }

  .desktop-floating-calc .calc-frac-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }

  .desktop-floating-calc .calc-frac-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink);
  }

  .desktop-floating-calc .calc-precision-toggle {
    display: flex;
    gap: 4px;
  }

  .desktop-floating-calc .calc-precision-opt {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    background: var(--surface2);
    cursor: pointer;
  }

  .desktop-floating-calc .calc-precision-opt.active {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
  }

  .desktop-floating-calc .calc-frac-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .desktop-floating-calc .calc-frac-opt {
    padding: 8px 4px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    font-family: var(--mono);
  }

  body.desktop-side-menu-mode .header-desktop-calc-btn.is-active {
    color: var(--accent);
    background: var(--surface2, rgba(255, 255, 255, 0.06));
  }
}
