/* ===== Mobil og iPhone =====
 * Ingen mus og lite plass: boksene ligger i et rutenett som scroller loddrett,
 * menylinjen er en fane-linje nederst, og dialoger kommer opp nedenfra.
 * Alt her gjelder bare smale skjermer, så datamaskinen ser ut som før. */
@media (max-width: 720px) {
  html,
  body {
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
  }
  body {
    -webkit-text-size-adjust: 100%;
  }
  #app {
    padding-top: env(safe-area-inset-top);
  }
  button,
  .btn,
  .chip {
    touch-action: manipulation;
  }

  /* Hjem */
  .tb.big {
    height: auto;
    min-height: 0;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 16px 6px !important;
    align-items: center;
  }
  html.isfs .tb.big {
    padding-top: 14px !important;
    height: auto;
  }
  .tb.big .gt {
    flex: 1 1 100%;
    order: 1;
  }
  .tb.big h1 {
    font-size: 24px;
    white-space: normal;
    overflow: visible;
  }
  .tb.big small {
    font-size: 13px;
  }
  .tb.big > :not(.gt) {
    order: 2;
  }
  .tb.big .fsb {
    display: none;
  }
  .tb.big .sp {
    display: none;
  }
  .tb.big .ab {
    height: 38px;
  }
  .tb.big .avb {
    margin-left: auto;
  }
  .cv {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 6px 14px calc(110px + env(safe-area-inset-bottom));
  }
  #stg {
    position: static !important;
    width: auto !important;
    height: auto !important;
    transform: none !important;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .cv .it {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    z-index: auto !important;
  }
  .cv .it.w {
    width: auto !important;
    height: auto !important;
    min-height: 136px;
  }
  .cv .it.w[style*="width:511px"] {
    grid-column: span 2;
    min-height: 150px;
  }
  .cv .it.st,
  .cv .it.dwi {
    grid-column: span 2;
    width: auto !important;
    height: auto !important;
    min-height: 150px;
  }
  .cv .it.dwi canvas {
    width: 100% !important;
    touch-action: none;
  }
  .cv:not(.ed) .w:hover {
    transform: none;
  }
  .w {
    padding: 14px;
  }
  .w .x {
    width: 28px;
    height: 28px;
  }
  .cv.ed .w .wctl {
    position: static;
    margin-top: 10px;
  }
  .cv.ed .it.w {
    padding-bottom: 12px;
  }
  .cv.ed .w {
    animation: none;
  }
  .pgb {
    display: none;
  }
  .wk button {
    padding: 4px 0;
  }
  .mo .mw {
    width: 140px;
  }
  .mo button {
    width: 26px;
    height: 26px;
  }
  .dyn {
    font-size: 44px;
  }

  /* Menylinje: fane-linje nederst, alltid synlig */
  .dock,
  .dock.mn,
  .dock.e5:not(.mn) {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: auto !important;
    height: 64px !important;
    transform: none;
    gap: 0;
    justify-content: space-around;
    padding: 0 6px;
    border-radius: 24px;
    background: color-mix(in srgb, var(--sf) 78%, transparent);
    box-shadow:
      0 0 0 0.5px color-mix(in srgb, var(--tx) 14%, transparent),
      0 10px 30px rgba(0, 0, 0, 0.2);
  }
  .dock .dk,
  .dock.mn .dk {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    opacity: 1;
    transform: none !important;
    pointer-events: auto;
  }
  .dock .dk:before,
  .dock .dmin,
  .dock .dind {
    display: none;
  }
  .dock.mn .dsep {
    opacity: 1;
  }
  .dock .dsep {
    height: 34px;
  }

  /* Dialoger: bunnark */
  .ov {
    align-items: flex-end !important;
  }
  .md {
    width: 100% !important;
    max-width: none !important;
    border-radius: 24px 24px 0 0 !important;
    max-height: 88vh;
    overflow-y: auto;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .pop.wide {
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 70vh;
    overflow-y: auto;
  }

  /* Profil og innstillinger */
  .pfw {
    flex-direction: column;
    padding: 8px 14px calc(120px + env(safe-area-inset-bottom)) !important;
    gap: 10px;
  }
  .pnv {
    width: 100% !important;
  }
  .pnv .pid {
    display: none;
  }
  .pnv nav {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 6px;
    scrollbar-width: none;
  }
  .pnv nav::-webkit-scrollbar {
    display: none;
  }
  .pnv nav button {
    flex: none;
    white-space: nowrap;
  }
  .pcn {
    width: 100%;
    min-width: 0;
  }
  .pro {
    flex-wrap: wrap;
    gap: 10px;
  }
  .lgb {
    min-width: 0;
  }
  .curp,
  .curp.cpc {
    grid-template-columns: repeat(2, 1fr);
  }
  .curp.cpc {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Oppsett */
  .dkarrow,
  .dknote {
    display: none;
  }
  .ob.withdock {
    padding-bottom: 20px;
  }
  .ob .dock {
    display: none;
  }
  .obc,
  .obc.wide {
    width: calc(100vw - 24px) !important;
    max-width: 520px;
  }
  .cty {
    grid-template-columns: 1fr;
  }

  /* Kalender og fokus */
  .tb {
    padding: 0 14px;
  }
  .tb:not(.big) h1 {
    font-size: 17px;
  }
}

/* Berøringsskjerm uten mus: ingen hover som blir hengende, og større trykkflater */
@media (hover: none) {
  .w:hover,
  .dk:hover,
  .btn:hover {
    transform: none !important;
  }
  .chip,
  .seg2 button,
  .cpk button {
    min-height: 38px;
  }
  .tdx,
  .x {
    opacity: 1;
  }
}

/* Justeringer etter test på telefon */
@media (max-width: 720px) {
  .cv .it.w {
    height: 172px !important;
    min-width: 0;
  }
  .cv .it.w[style*="width:511px"] {
    height: auto !important;
    min-height: 172px;
  }
  .cv .it.w .t2 {
    overflow-wrap: anywhere;
  }
  .mo {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .mo .mw {
    width: 100%;
    flex: 1 1 100%;
    margin: 0;
  }
  .mo .me2 {
    flex: 1 1 100%;
  }
  .ob {
    grid-template-columns: minmax(0, 1fr) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  .obc,
  .obc.wide,
  .obc.wel {
    width: calc(100vw - 24px) !important;
    min-width: 0 !important;
    max-width: 520px;
    box-sizing: border-box;
    margin: 0 !important;
    justify-self: center;
  }
  .obc.wel {
    display: block !important;
  }
  /* Kalender: kompakt topplinje og prikker i stedet for tekst i rutene */
  .tb:not(.big) {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding: 8px 12px;
    row-gap: 4px;
  }
  .tb:not(.big) small {
    display: none;
  }
  .tb > .holb {
    margin-left: 0;
    order: 5;
  }
}

@media (max-width: 720px) {
  .cl {
    min-height: 62px;
    padding: 4px 2px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    gap: 2px 3px;
  }
  .cl > b {
    flex: 1 1 100%;
    text-align: center;
  }
  .cl .ch {
    width: 7px;
    height: 7px;
    min-width: 0;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
    overflow: hidden;
    background: var(--c);
    border: 0;
  }
  .cl .ch * {
    display: none;
  }
  .cl .hl,
  .cl .stu,
  .cl .sub {
    display: none;
  }
  .cg {
    grid-template-columns: 1fr !important;
    overflow-y: auto;
    padding-bottom: calc(110px + env(safe-area-inset-bottom));
  }
  .cg .insp {
    width: auto;
    border-left: 0;
    border-top: 0.5px solid var(--ln);
    padding: 14px;
  }
  .cm {
    --rh: auto;
  }
}

.nbk {
  display: none;
}
@media (max-width: 720px) {
  .nt {
    display: block !important;
    position: relative;
    height: 100%;
  }
  .nt .nl {
    width: 100% !important;
    max-width: none;
    border-right: 0;
    height: 100%;
    padding-bottom: 110px;
  }
  .nt .ed {
    width: 100% !important;
    height: 100%;
  }
  .nt .ed.nempty {
    display: none;
  }
  .nt.open .nl {
    display: none;
  }
  .nbk {
    display: inline-flex;
    align-items: center;
    margin: 10px 12px 0;
    padding: 8px 12px;
    border-radius: 99px;
    background: var(--sf2);
    font-weight: 650;
    font-size: 14px;
    color: var(--ac);
  }
  .cv.ed .w .wctl {
    margin: 30px 0 8px;
  }
}
