/* ══════════════════════════════════════════════════
   MOBILE / TABLET EDITION
   Light, flat and fast: no glows, blurs, gradients or
   scroll animations, so it stays smooth on any phone.
══════════════════════════════════════════════════ */
.m-app { display: none; }

@media (max-width: 1024px), (pointer: coarse) and (max-width: 1366px) {

  /* Switch off the desktop edition (and its effects) */
  #loadScreen, .wallpaper, #desktop, #projectViewer, #lightbox,
  .c-dot, .c-ring, #shutdownScreen, .icon-sprite ~ .wallpaper { display: none !important; }

  html, body {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
    background: #fafaf8;
    scroll-padding-top: 64px;
  }
  body, a, button { cursor: auto !important; }
  a, button { cursor: pointer !important; }
  html.m-lock, html.m-lock body { overflow: hidden; }

  .m-app {
    --bg: #fafaf8;
    --surface: #ffffff;
    --line: #e6e4df;
    --ink: #141414;
    --ink-2: #3d3d3d;
    --muted: #6f6f6b;
    --accent: #e8440c;
    --tab-h: 58px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);

    display: block;
    min-height: 100vh;
    font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
  }
  .m-app svg { width: 1em; height: 1em; flex-shrink: 0; }
  .m-app img { max-width: 100%; }
  .m-app :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .m-app [hidden] { display: none !important; }
  .m-app ol, .m-app ul { list-style: none; }

  /* ── Top bar ── */
  .m-top {
    position: fixed; z-index: 50; top: 0; left: 0; right: 0;
    height: calc(56px + var(--safe-t));
    padding: var(--safe-t) 20px 0;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg);
    border-bottom: 1px solid transparent;
  }
  .m-top.is-scrolled { border-bottom-color: var(--line); }
  .m-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
  .m-brand img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
  .m-top-links { display: flex; gap: 4px; }
  .m-top-link { font-size: 15px; font-weight: 500; color: var(--accent); padding: 8px 0 8px 12px; }
  button.m-top-link { color: var(--ink); }

  .m-main {
    max-width: 720px; margin: 0 auto;
    padding: calc(56px + var(--safe-t)) 0 calc(var(--tab-h) + var(--safe-b) + 16px);
  }

  /* ── Type ── */
  .m-h2 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 18px; }
  .m-h3 { font-size: 17px; font-weight: 600; margin: 32px 0 12px; }
  .m-lead { font-size: 16px; color: var(--ink-2); }
  .m-muted { color: var(--muted); font-size: 14px; }

  /* ── Buttons ── */
  .m-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 46px; padding: 0 18px; border-radius: 10px;
    font-size: 15px; font-weight: 600;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  }
  .m-btn svg { width: 18px; height: 18px; color: #1fa855; }
  .m-btn-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
  .m-btn:active { opacity: 0.75; }

  /* ── Hero ── */
  .m-hero { padding: 28px 20px 36px; border-bottom: 1px solid var(--line); }
  .m-avatar { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; display: block; }
  .m-status { display: inline-flex; align-items: center; gap: 7px; margin-top: 18px; font-size: 13px; font-weight: 500; color: #15803d; }
  .m-status i { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }
  .m-name { margin-top: 6px; font-size: 34px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
  .m-title { margin: 4px 0 14px; font-size: 17px; font-weight: 500; color: var(--accent); }
  .m-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
  .m-numbers { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 26px; border-top: 1px solid var(--line); padding-top: 16px; }
  .m-numbers dt { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
  .m-numbers dd { font-size: 12px; color: var(--muted); line-height: 1.3; }

  /* ── Sections ── */
  .m-section { padding: 36px 20px; border-bottom: 1px solid var(--line); }

  /* Design / Software switch */
  .m-seg { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; margin-bottom: 16px; border-radius: 10px; background: #efeeea; }
  .m-seg button { height: 38px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
  .m-seg button.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

  .m-filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -20px 16px; padding: 0 20px; }
  .m-filters::-webkit-scrollbar { display: none; }
  .m-filter {
    flex-shrink: 0; height: 34px; padding: 0 13px; border-radius: 17px;
    font-size: 13.5px; font-weight: 500; color: var(--ink-2);
    border: 1px solid var(--line); background: var(--surface);
  }
  .m-filter.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }

  /* Project grid */
  .m-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 12px; }
  .m-card { display: block; width: 100%; text-align: left; }
  .m-card-img { display: block; aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; background: #ecebe7; }
  .m-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .m-card-name { display: block; margin-top: 8px; font-size: 14.5px; font-weight: 600; line-height: 1.3; }
  .m-card-meta { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
  .m-card:active .m-card-img { opacity: 0.85; }

  .m-row-link {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 22px; padding: 14px 16px; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--line);
    font-size: 15px; font-weight: 500;
  }
  .m-row-link svg { width: 18px; height: 18px; color: var(--muted); }

  /* Software */
  .m-case { padding: 20px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
  .m-case-kicker { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
  .m-case h3 { margin: 6px 0 4px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
  .m-case > p:not(.m-case-kicker):not(.m-tags) { margin-top: 12px; font-size: 15px; color: var(--ink-2); }
  .m-case > p.m-muted { margin-top: 0 !important; font-size: 13.5px !important; color: var(--muted) !important; }
  .m-case h4 { margin: 18px 0 6px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
  .m-case ul { display: grid; gap: 6px; }
  .m-case li { position: relative; padding-left: 16px; font-size: 15px; color: var(--ink-2); }
  .m-case li::before { content: ''; position: absolute; left: 2px; top: 10px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
  .m-case .m-tags { margin-top: 18px; }

  .m-deflist { display: grid; gap: 0; border-top: 1px solid var(--line); }
  .m-deflist > div { padding: 14px 0; border-bottom: 1px solid var(--line); }
  .m-deflist dt { font-size: 15px; font-weight: 600; }
  .m-deflist dd { margin-top: 2px; font-size: 14.5px; color: var(--ink-2); }

  .m-tags { display: flex; flex-wrap: wrap; gap: 6px; }
  .m-tags span { padding: 5px 10px; border-radius: 6px; font-size: 13px; color: var(--ink-2); background: #efeeea; }

  /* Experience */
  .m-exp { display: grid; border-top: 1px solid var(--line); }
  .m-exp li { padding: 16px 0; border-bottom: 1px solid var(--line); }
  .m-exp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
  .m-exp-head strong { font-size: 16px; font-weight: 600; }
  .m-exp-head span { flex-shrink: 0; font-size: 13px; color: var(--muted); }
  .m-exp-role { margin-top: 1px; font-size: 14px; font-weight: 500; color: var(--accent); }
  .m-exp li > p:last-child { margin-top: 6px; font-size: 14.5px; color: var(--ink-2); }
  .m-edu { padding: 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
  .m-edu .m-muted { margin-top: 4px; }

  /* Certificates */
  .m-certs { display: grid; gap: 12px; }
  .m-cert { display: block; width: 100%; text-align: left; border-radius: 12px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
  .m-cert img { display: block; width: 100%; height: auto; aspect-ratio: 640 / 450; object-fit: cover; background: #ecebe7; border-bottom: 1px solid var(--line); }
  .m-cert span { display: flex; flex-direction: column; padding: 12px 14px 13px; }
  .m-cert strong { font-size: 15.5px; font-weight: 600; }
  .m-cert small { font-size: 13px; color: var(--muted); line-height: 1.4; }
  .m-cert:active { opacity: 0.85; }
  @media (min-width: 640px) { .m-certs { grid-template-columns: 1fr 1fr; } }

  /* Skills */
  .m-skillgroup + .m-skillgroup { margin-top: 20px; }
  .m-skillgroup h3 { margin-bottom: 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

  /* Contact */
  .m-contact { display: grid; margin-top: 18px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
  .m-contact a { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
  .m-contact a + a { border-top: 1px solid var(--line); }
  .m-contact svg { width: 20px; height: 20px; color: var(--ink-2); }
  .m-contact a:first-child svg { color: #1fa855; }
  .m-contact span { display: flex; flex-direction: column; font-size: 15px; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
  .m-contact small { font-size: 12.5px; font-weight: 400; color: var(--muted); }
  .m-contact a:active { background: #f3f2ee; }
  .m-footer { margin-top: 28px; font-size: 13px; color: var(--muted); text-align: center; }
  #m-contact { border-bottom: 0; }

  /* ── Tab bar ── */
  .m-tabbar {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .m-tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 500; color: #8a8a86; }
  .m-tabbar svg { width: 22px; height: 22px; }
  .m-tabbar a.is-active { color: var(--ink); }
  .m-tabbar a.is-active svg { color: var(--accent); }

  /* ── Project page ── */
  .m-sheet {
    position: fixed; z-index: 100; inset: 0;
    display: flex; flex-direction: column; background: var(--bg);
    transform: translateX(100%); visibility: hidden;
    transition: transform 260ms ease-out, visibility 0s linear 260ms;
  }
  .m-sheet.is-open { transform: none; visibility: visible; transition: transform 260ms ease-out, visibility 0s; }
  .m-sheet-bar {
    flex-shrink: 0; display: grid; grid-template-columns: 44px 1fr 56px; align-items: center;
    height: calc(56px + var(--safe-t)); padding: var(--safe-t) 10px 0;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .m-sheet-title { font-size: 15px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-sheet-count { font-size: 13px; color: var(--muted); text-align: right; padding-right: 6px; font-variant-numeric: tabular-nums; }
  .m-icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; color: var(--ink); }
  .m-icon-btn svg { width: 22px; height: 22px; }
  .m-icon-btn:active { background: #efeeea; }
  .m-icon-btn-dark { color: #fff; }
  .m-icon-btn-dark:active { background: rgba(255,255,255,0.15); }
  .m-sheet-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

  .m-pv-head { padding: 22px 20px 6px; max-width: 720px; margin: 0 auto; }
  .m-pv-meta { font-size: 13px; color: var(--muted); }
  .m-pv-meta #mpCat { color: var(--accent); font-weight: 600; }
  .m-pv-name { margin: 6px 0 10px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
  .m-pv-desc { font-size: 15.5px; color: var(--ink-2); }
  .m-pv-head .m-tags { margin-top: 14px; }

  .m-pv-gallery { display: grid; gap: 12px; padding: 18px 20px 8px; max-width: 720px; margin: 0 auto; }
  .m-pv-item { display: block; width: 100%; text-align: left; }
  .m-pv-item img, .m-pv-item video { display: block; width: 100%; height: auto; border-radius: 8px; background: #ecebe7; }
  .m-pv-item img { min-height: 160px; }
  .m-pv-item img[data-loaded] { min-height: 0; }
  .m-pv-cap { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }

  .m-pv-foot { padding: 12px 20px calc(28px + var(--safe-b)); max-width: 720px; margin: 0 auto; }
  .m-next { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
  .m-next-img { width: 56px; height: 56px; border-radius: 8px; overflow: hidden; background: #ecebe7; flex-shrink: 0; }
  .m-next-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .m-next-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
  .m-next-txt small { font-size: 12.5px; color: var(--muted); }
  .m-next-txt strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-next > svg { width: 20px; height: 20px; color: var(--muted); }

  /* ── Image viewer ── */
  .m-lb { position: fixed; inset: 0; z-index: 120; display: none; flex-direction: column; background: #000; }
  .m-lb.is-open { display: flex; }
  .m-lb-bar { position: absolute; z-index: 2; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-t) + 8px) 10px 8px 18px; background: rgba(0,0,0,0.55); }
  .m-lb-count { font-size: 14px; color: #fff; font-variant-numeric: tabular-nums; }
  .m-lb-track { flex: 1; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior: contain; }
  .m-lb-track::-webkit-scrollbar { display: none; }
  .m-lb-slide { flex: 0 0 100%; height: 100%; display: grid; place-items: center; scroll-snap-align: center; scroll-snap-stop: always; padding: 56px 0 60px; }
  .m-lb-slide img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
  .m-lb-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 20px calc(12px + var(--safe-b)); font-size: 14px; color: #ddd; text-align: center; background: rgba(0,0,0,0.55); }

  /* ── Tablets ── */
  @media (min-width: 640px) {
    .m-grid { grid-template-columns: repeat(3, 1fr); }
    .m-hero, .m-section { padding-left: 32px; padding-right: 32px; }
    .m-filters { margin-left: -32px; margin-right: -32px; padding-left: 32px; padding-right: 32px; }
    .m-actions { max-width: 380px; }
    .m-pv-gallery { grid-template-columns: 1fr 1fr; }
    .m-pv-gallery .is-wide { grid-column: 1 / -1; }
  }

  @media (max-width: 350px) {
    .m-numbers { grid-template-columns: repeat(2, 1fr); row-gap: 12px; }
    .m-tabbar span { font-size: 10px; }
  }

  @media (prefers-reduced-motion: reduce) {
    .m-sheet, .m-sheet.is-open { transition: none; }
  }
}
