/* The shared controls also render in the desktop header. */
.app-header .phone-only[hidden] {display:none!important}
.header-status-panel {display:contents}

@media (max-width:700px), (orientation:landscape) and (pointer:coarse) and (max-height:520px) and (max-width:1000px) {
  :root {
    --phone-edge:clamp(12px,3.6vw,18px);
    --phone-dock:calc(60px + env(safe-area-inset-bottom,0px));
    scroll-padding-bottom:calc(var(--phone-dock) + 12px);
  }
  .sidebar {display:none}
  .main {margin:0;padding:0 0 var(--phone-dock);min-width:0;min-height:calc(100svh - 78px)}
  .main>.content {
    width:100%;min-width:0;max-width:none;margin:0;
    padding:12px max(var(--phone-edge),env(safe-area-inset-right)) 14px max(var(--phone-edge),env(safe-area-inset-left));
  }
  .topbar.app-header {
    position:relative;inset:auto;z-index:30;height:auto;
    padding:calc(6px + env(safe-area-inset-top,0px)) max(var(--phone-edge),env(safe-area-inset-right)) 12px max(var(--phone-edge),env(safe-area-inset-left));
    display:grid;grid-template-columns:minmax(0,1fr) auto auto auto;
    grid-template-rows:46px auto;column-gap:6px;row-gap:8px;
    color:var(--text);background:var(--surface);border-bottom:1px solid var(--border);
  }
  /* The phone header uses the workspace surface, not the dark desktop banner.
     Inherit the palette's muted text instead of the banner's pale override. */
  :root .topbar.app-header {--muted:inherit}
  .app-header .header-context,.app-header .header-actions {display:contents}
  .app-header .header-status-panel {
    grid-area:2/1/3/-1;display:flex;align-items:center;justify-content:space-between;
    gap:12px;min-width:0;padding:10px 12px;border:1px solid var(--border);
    border-radius:17px;background:var(--surface-soft);
  }
  .app-header .header-brand,.app-header:has(.focus-launch) .header-brand {
    grid-area:1/1;display:inline-flex;gap:8px;width:fit-content;
    min-width:0;max-width:100%;height:44px;padding:0;border:0;color:var(--text);
  }
  .app-header .header-mark {width:30px;height:30px}
  .app-header .header-wordmark {display:none}
  .app-header .phone-page-title[hidden] {
    display:block!important;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
    font-size:18px;font-weight:680;letter-spacing:-.045em;
  }
  .app-header .focus-launch,.app-header .ai-open,.app-header .phone-tools-toggle[hidden] {
    width:44px;height:44px;min-height:44px;min-width:44px;align-items:center;justify-content:center;
    padding:0;border:1px solid var(--border);border-radius:15px;background:var(--surface-soft);color:var(--text);box-shadow:none;
  }
  .app-header .focus-launch {grid-area:1/2}
  .app-header .ai-open {grid-area:1/3;background:var(--accent-soft);color:var(--accent)}
  .app-header .phone-tools-toggle[hidden] {display:inline-flex!important;grid-area:1/4}
  .app-header :is(.focus-launch,.ai-open) span {display:none}
  .app-header .ai-open .ai-label-short,.app-header .ai-open .ai-label-full {display:none}
  .app-header .phone-tools-toggle[aria-expanded=true] {background:var(--surface-soft)}
  .app-header .header-clock {
    grid-area:auto;display:flex;flex-direction:column;gap:2px;align-items:flex-start;
    font-size:12px;line-height:1.5;color:var(--text);letter-spacing:0;
  }
  .app-header .header-date-full {display:none}
  .app-header .header-date-compact {display:inline}
  .app-header .header-clock time {font-size:11px;color:var(--muted)}
  .app-header .header-streak {
    grid-area:auto;align-self:center;justify-self:auto;
    height:auto;min-height:38px;padding:7px 9px;border:0;border-radius:12px;
    background:var(--accent-soft);color:var(--text);gap:6px;
  }
  .app-header .streak-copy {display:flex;flex-direction:row;gap:3px;align-items:baseline}
  .app-header .streak-copy strong,.app-header .streak-label {font-size:11px;color:inherit}
  .app-header .streak-icon {color:var(--accent)}
  .app-header .streak-icon .icon {width:14px;height:14px}
  .app-header .header-tools {display:none}
  .app-header:has(.phone-tools-toggle[aria-expanded=true]) .header-tools {
    position:absolute;inset:calc(58px + env(safe-area-inset-top)) var(--phone-edge) auto auto;
    grid-area:auto;display:flex;flex-flow:column;align-items:stretch;
    width:min(240px,calc(100vw - 2 * var(--phone-edge)));height:auto;
    padding:6px;border:1px solid var(--border);border-radius:16px;
    background:var(--surface);color:var(--text);box-shadow:0 10px 36px #0002;
  }
  .app-header .header-tools>.icon-button,.app-header .header-tools>.phone-settings[hidden] {
    justify-content:flex-start;gap:12px;width:100%;height:46px;padding:0 12px;
    font-size:14px;color:var(--text);background:transparent;border-radius:10px;
  }
  .app-header .header-tools>.phone-settings[hidden] {display:inline-flex!important}
  .app-header .header-tools>.icon-button::after {content:attr(aria-label);text-align:start}
  .app-header .header-tools>.icon-button:hover {background:var(--surface-soft);color:var(--text)}
  .app-header :is(button,a):focus-visible {outline:2px solid var(--accent);outline-offset:-2px}
  .mobile-nav {
    position:fixed;inset:auto 0 0;z-index:25;width:100%;box-sizing:border-box;
    display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:0;height:var(--phone-dock);
    padding:3px max(3px,env(safe-area-inset-right)) calc(3px + env(safe-area-inset-bottom)) max(3px,env(safe-area-inset-left));
    border-top:1px solid var(--border);background:var(--surface);box-shadow:0 -2px 14px #00000006;
  }
  .mobile-nav button {
    display:flex;flex-flow:column;align-items:center;justify-content:center;gap:2px;
    position:relative;isolation:isolate;width:100%;min-width:0;padding:1px 0;
    color:var(--muted);background:none;border:0;border-radius:10px;
  }
  .mobile-nav button .icon {width:21px;height:21px}
  .mobile-nav button span {font-size:10px;line-height:14px;min-height:0;white-space:nowrap;font-weight:550}
  .mobile-nav button.active {color:var(--accent)}
  .mobile-nav button.active span {font-weight:700}
  .mobile-nav button.active::before {
    content:'';position:absolute;z-index:-1;top:calc(50% - 22px);left:50%;transform:translateX(-50%);
    width:40px;height:27px;border-radius:99px;background:var(--accent-soft);
  }
  .mobile-nav button:active,.app-header button:active {background:var(--accent-soft)}
  .main .panel {min-width:0}
  .main :is(input,textarea,select) {max-width:100%;scroll-margin-block:16px calc(var(--phone-dock) + 12px)}
  #toast {bottom:calc(var(--phone-dock) + 9px)}
}
@media (orientation:landscape) and (pointer:coarse) and (max-height:520px) and (max-width:1000px) {
  :root {--phone-dock:calc(44px + env(safe-area-inset-bottom,0px))}
  .mobile-nav button {flex-direction:row;gap:5px}
  .mobile-nav button.active::before {display:none}
  .mobile-nav button.active {background:var(--accent-soft)}
}
