[data-mobile-only], .app-tabs, .app-back { display: none !important; }
.app-profile {
  width: min(92%, 64rem);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 5rem) 0;
}
.app-profile-card, .app-profile nav, .app-preferences {
  border: 1px solid var(--portfolio-line);
  border-radius: var(--portfolio-radius);
  background: var(--portfolio-surface);
}
.app-profile-card { display: grid; grid-template-columns: clamp(80px, 24vw, 110px) minmax(0, 1fr); align-items: start; gap: 1.3rem; padding: 1.5rem; }
.app-profile-card img { width: 100%; height: auto; border-radius: var(--portfolio-control-radius); }
.app-profile-card h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: 1.15; }
.app-profile-card p { color: var(--portfolio-muted); font-size: 1.35rem; margin-top: .4rem; }
.app-profile nav, .app-preferences { margin-top: 1.35rem; }
.app-profile ul { list-style: none; }
.app-profile nav a, .app-preferences button {
  display: flex;
  min-height: 44px;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.35rem;
  background: transparent;
  color: var(--portfolio-text);
  border: 0;
  text-align: start;
  font: 600 1.45rem/1.3 system-ui, sans-serif;
}
.app-profile nav li + li,
.app-profile nav > * + * { border-top: 1px solid var(--portfolio-line); }
.app-profile nav h2 {
  margin: 0;
  padding: 1.1rem 1.35rem .3rem;
  color: var(--portfolio-blue);
  font: 700 1.3rem/1.3 system-ui, sans-serif;
}
.app-profile nav a:hover, .app-preferences button:hover { background: var(--portfolio-hover); }
.app-profile nav a svg { color: var(--portfolio-blue); flex: none; }
.app-preferences h2 { padding: 1.1rem 1.35rem .35rem; font-size: 1.65rem; }
.app-install { border-top: 1px solid var(--portfolio-line); }
.app-install button { color: var(--portfolio-blue); }
.app-install p { padding: .9rem 1.35rem; color: var(--portfolio-muted); font-size: 1.35rem; }
.app-preferences [hidden] { display: none; }

.app-offline {
  background: var(--portfolio-bg); color: var(--portfolio-text); margin: 0;
  font: 16px/1.6 system-ui, sans-serif;
}
.app-offline main { width: min(88%, 500px); margin: clamp(70px, 18dvh, 210px) auto; }
.app-offline nav { display: flex; gap: 20px; }
.app-offline a { color: var(--portfolio-blue); }

@media screen and (max-width: 767px), screen and (max-height: 500px) and (max-width: 960px) and (pointer: coarse) {
  :root {
    --site-header-height: calc(54px + env(safe-area-inset-top));
    --app-tab-height: calc(62px + env(safe-area-inset-bottom));
    scroll-padding-bottom: var(--app-tab-height);
  }
  body:has(.app-tabs) { padding-bottom: var(--app-tab-height); }
  .site-header[data-site-header] {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions";
    padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    gap: 4px;
  }
  .site-header[data-site-header]:has(.app-back) {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "back brand actions";
  }
  .site-header .site-brand { font-size: 15px; overflow: hidden; text-overflow: ellipsis; width: auto; }
  .site-header #menu, .site-header .site-nav { display: none !important; }
  .site-header .site-control { min-width: 44px; height: 44px; border-color: transparent; }
  .site-header .app-back { display: grid !important; grid-area: back; }
  .app-tabs[data-mobile-only] {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    z-index: 999;
    inset: auto 0 0;
    min-height: var(--app-tab-height);
    padding: 3px max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
    box-sizing: border-box;
    background: var(--portfolio-surface);
    border-top: 1px solid var(--portfolio-line);
    font: 600 11px/1.2 system-ui, sans-serif;
  }
  .app-keyboard-open .app-tabs[data-mobile-only] { visibility: hidden; }
  .app-tabs a {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    min-height: 54px;
    color: var(--portfolio-muted);
    text-decoration: none;
    text-align: center;
  }
  .app-tab-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 27px;
    border-radius: 10px;
    transition: background-color .17s ease, transform .17s ease;
  }
  .app-tabs a[aria-current] { color: var(--portfolio-blue); }
  .app-tabs a[aria-current] .app-tab-icon { background: var(--portfolio-tint); }
  .app-tabs a:active .app-tab-icon { transform: scale(.9); background: var(--portfolio-hover); }
  .portfolio-page #scroll-top {
    top: auto;
    bottom: calc(var(--app-tab-height) + 8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .portfolio-page #scroll-top.active { top: auto; opacity: 1; visibility: visible; pointer-events: auto; }
  .footer .box-container .box > a {
    display: flex;
    align-items: center;
    gap: .45rem;
    min-height: 44px;
  }
  .footer .box-container .box .share a { min-width: 44px; min-height: 44px; }
  .portfolio-page .section-band { padding-block: 2.9rem; }
  .portfolio-page .portfolio-hero {
    grid-template-columns: minmax(0,1fr);
    padding-block: 2.4rem 2.1rem;
    gap: 1.5rem;
  }
  .portfolio-hero h1 { font-size: clamp(3rem, 9vw, 4.2rem); }
  .portfolio-hero .portfolio-role { font-size: 1.7rem; }
  .portfolio-hero .portfolio-summary { font-size: 1.45rem; margin: .75rem 0 1.35rem; }
  .portfolio-hero .portfolio-actions { gap: .65rem; }
  .portfolio-hero .portfolio-actions :is(a, button) { padding: .8rem 1rem; min-height: 44px; font-size: 1.35rem; display: inline-flex; align-items: center; gap: .5rem; }
  .portfolio-page .portfolio-hero .portfolio-links { margin-top: 1rem; }
  .portfolio-hero .portfolio-stack { padding: .85rem; }
  .portfolio-hero .portfolio-stack h2 { font-size: 1.35rem; margin-bottom: .65rem; }
  .portfolio-hero .portfolio-stack ul { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .4rem; }
  .portfolio-hero .portfolio-stack li { padding: .35rem; font-size: 1.1rem; }
  .portfolio-hero .portfolio-stack img { width: 16px; height: 16px; }
  .app-shortcuts[data-mobile-only] { display: block !important; padding: 1.5rem var(--section-inline) 2.25rem; }
  .app-shortcuts h2 { font-size: 1.8rem; margin-bottom: .85rem; }
  .app-shortcut-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .7rem; }
  .app-shortcut-grid a {
    display: flex; align-items: flex-start; gap: .65rem; min-height: 62px; min-width: 0;
    padding: .8rem; color: var(--portfolio-text); background: var(--portfolio-surface);
    border: 1px solid var(--portfolio-line); border-radius: var(--portfolio-radius);
    text-decoration: none;
  }
  .app-shortcut-grid a:active { background: var(--portfolio-hover); }
  .app-shortcut-grid svg { color: var(--portfolio-blue); flex: none; width: 18px; height: 18px; }
  .app-shortcut-grid strong, .app-shortcut-grid small { display: block; overflow-wrap: anywhere; }
  .app-shortcut-grid strong { font-size: 1.2rem; line-height: 1.2; }
  .app-shortcut-grid small { color: var(--portfolio-muted); font-size: 1.1rem; line-height: 1.25; margin-top: .24rem; }
  .app-sheet[open], #skillModal[open], #lab-dialog[open] {
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: 88dvh;
    margin: 0;
    border-radius: 20px 20px 0 0;
    animation: app-sheet-in .18s ease-out;
  }
  @keyframes app-sheet-in { from { translate: 0 12px; opacity: .6; } to { translate: 0 0; opacity: 1; } }
  :is(.app-sheet, #skillModal, #lab-dialog) .skill-detail {
    max-height: calc(88dvh - 2px);
    padding-bottom: calc(1.6rem + env(safe-area-inset-bottom));
  }
  :is(.app-sheet, #skillModal, #lab-dialog) .skill-detail::before {
    content: ""; display: block; width: 34px; height: 4px; margin: 0 auto .65rem;
    border-radius: 6px; background: var(--portfolio-control-line);
  }
  #cvModal[open] {
    inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: none;
    margin: 0; border: 0; border-radius: 0;
  }
  #cvContent {
    min-height: 100%; max-height: 100dvh;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
    border-radius: 0;
  }
  #cvContent .cv-close { position: sticky; float: right; top: 0; margin: .6rem; width: 44px; height: 44px; }
  #cvContent .cv-actions { position: sticky; top: 0; padding: .6rem; background: var(--portfolio-surface); }
  #cvContent .cv-print, #cvContent .cv-drive { min-height: 44px; }
  #cvContent .cv-sheet { padding: 1.2rem 1.5rem; }
  #cvContent .cv-head { align-items: flex-start; gap: .85rem; }
  #cvContent .cv-photo { width: 5.8rem; height: auto; }
  #cvContent .cv-head-info { min-width: 0; overflow-wrap: anywhere; }
  #cvContent .cv-head-info h1 { font-size: 2rem; }
  .portfolio-page :is(input:not([type=checkbox]), textarea, select), .command-portal-page :is(input:not([type=checkbox]), textarea, select) {
    font-size: 16px;
  }
  .command-library .library-code pre {
    white-space: pre; overflow-x: auto; overflow-wrap: normal; max-width: 100%; font-size: 13px;
  }
  .command-library :is(.library-copy, .library-tag, .library-quiet), .lab-node, .modal-controls button {
    min-height: 44px;
  }
  .command-portal-page .library-toast:not(:empty) { bottom: calc(var(--app-tab-height) + 8px); }
  .lab-page .lab-band { padding-block: 2.8rem; }
  .lab-hero { padding-block: 2.7rem; }
  .lab-hero .lab-wrap, .lab-architecture { grid-template-columns: minmax(0,1fr); }
  .lab-shared-layer { margin: 1rem 0 0; padding: 0; border: none; }
  .lab-primary-layers .lab-layer::after, .lab-shared-layer .lab-layer::before { content: none; }
  .lab-roadmap summary { min-height: 44px; align-content: center; }
  .lab-platforms .lab-platform { border-color: var(--portfolio-control-line); }
  .listing-page .blog-grid { width: 100%; grid-template-columns: 1fr; gap: .8rem; }
  .listing-page .blog-card { display: grid; grid-template-columns: 72px minmax(0,1fr); }
  .listing-page .blog-card-thumb {
    height: 100%; min-height: 85px; font-size: 2.15rem; align-content: start; overflow: hidden;
  }
  .listing-page .blog-card-thumb.has-logo img { width: 4.4rem; height: 4.4rem; padding: .5rem; }
  .listing-page .blog-card-thumb .project-badge { display: none; }
  .listing-page .blog-card-body { padding: .8rem 1rem; }
  .listing-page .blog-card-body h3 { font-size: 1.5rem; }
  .listing-page .blog-card-foot { margin-top: .7rem; padding-top: 0; flex-wrap: wrap; }
  .listing-page .blog-card-foot :is(a, button), .listing-page .blog-back { min-height: 44px; display: inline-flex; align-items: center; gap: .35rem; }
  .listing-page .blog-detail-wrap { width: 100%; }
  .listing-page .blog-detail > p { line-height: 1.75; }
  .listing-page .blog-detail .code-copy { min-height: 44px; }
  .blog-toolbar > .skill-filters { display: none; }
  .app-preview-button[data-mobile-only], .app-filter-button[data-mobile-only] {
    display: inline-flex !important;
    padding: .4rem .75rem;
    align-items: center;
    min-height: 44px;
    border: 1px solid var(--portfolio-line);
    border-radius: var(--portfolio-control-radius);
    background: var(--portfolio-surface);
    color: var(--portfolio-blue);
    font-weight: 600;
    cursor: pointer;
  }
  .app-sheet h2 { margin-bottom: .75rem; font-size: 2rem; }
  .app-sheet p { color: var(--portfolio-muted); line-height: 1.65; }
  .app-sheet .skill-filters { display: flex; flex-wrap: wrap; gap: .55rem; }
  .app-sheet .skill-filter, .app-sheet-link {
    display: inline-flex; align-items: center; min-height: 44px; padding: .5rem .9rem;
    border: 1px solid var(--portfolio-line); border-radius: var(--portfolio-control-radius);
    color: var(--portfolio-blue); background: var(--portfolio-surface);
  }
  .app-sheet .skill-filter.active, .app-sheet-link {
    color: var(--portfolio-on-accent); background: var(--portfolio-blue);
  }
  .app-sheet-link { margin-top: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .app-tabs *, .app-sheet[open], #skillModal[open], #lab-dialog[open] { animation: none; transition: none; }
}
@media print {
  .app-profile .app-preferences, .app-tabs { display: none !important; }
}
@media screen and (max-width: 767px), screen and (max-height: 500px) and (max-width: 960px) and (pointer: coarse) {
  .app-card-category[data-mobile-only] {
    display: block !important;
    color: var(--portfolio-blue);
    margin: -.25rem 0 .45rem;
    font-size: 1.1rem;
    font-weight: 600;
  }
  .app-layer-heading { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
  .app-layer-toggle[data-mobile-only] {
    display: grid !important; place-items: center; min-width: 44px; min-height: 44px;
    margin-inline-start: auto; cursor: pointer; color: var(--portfolio-blue);
    background: var(--portfolio-surface); border: 1px solid var(--portfolio-line);
    border-radius: var(--portfolio-control-radius);
  }
  .app-layer-toggle[aria-expanded="false"] span { transform: rotate(-90deg); }
  .lab-layer:has(.app-layer-toggle[aria-expanded="false"]) .lab-nodes { display: none; }
  .lab-roadmap { border-inline-start: 1px solid var(--portfolio-control-line); padding-inline-start: .85rem; }
}

@media screen and (max-width: 767px), screen and (max-height: 500px) and (max-width: 960px) and (pointer: coarse) {
  #projGrid .project-desktop-actions { display: none; }
  #projGrid .project-mobile-actions[data-mobile-only] {
    display: grid !important;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    border-top: 1px solid var(--portfolio-line);
  }
  #projGrid .project-mobile-actions :is(button, a) {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: 44px;
    padding: 5px 6px;
    border: 1px solid var(--portfolio-line);
    border-radius: var(--portfolio-control-radius);
    font: 700 13px/1.2 system-ui, sans-serif;
    text-align: center;
    overflow-wrap: anywhere;
    cursor: pointer;
  }
  #projGrid .project-mobile-actions svg { flex: none; }
  #projGrid .project-mobile-preview {
    background: var(--portfolio-tint);
    color: var(--portfolio-blue);
  }
  #projGrid .project-mobile-details {
    border-color: var(--portfolio-blue);
    background: var(--portfolio-blue);
    color: var(--portfolio-on-accent);
  }
  #projGrid .project-mobile-preview:is(:hover, :active) { background: var(--portfolio-hover); }
  #projGrid .project-mobile-details:is(:hover, :active) { filter: brightness(.9); }
}
