/* Keep the existing form and integration styles below the native workspace presentation. */
@layer ios-workspace {
  :root {
    --ios-ink: #111827;
    --ios-muted: #5b616f;
    --ios-lime: #c7f73d;
    --ios-glass: rgb(255 255 255 / .65);
    --ios-line: rgb(255 255 255 / .88);
    --ios-font: "TaskHub Interface", system-ui, sans-serif;
    --ios-canvas:
      radial-gradient(ellipse at top left, #dae3f7, transparent 62%),
      radial-gradient(ellipse at bottom right, #ebf2cc, transparent 62%),
      #f2f2f7;
  }

  body {
    display: flow-root !important;
    min-height: 100dvh;
    background: var(--ios-canvas) fixed !important;
    color: var(--ios-ink) !important;
  }
  #shell, #login, #shell :is(h1, h2, h3, button, input, textarea, select), #login :is(h1, h2, button, input) {
    font-family: var(--ios-font) !important;
  }

  #login {
    width: min(420px, calc(100% - 36px)) !important;
    max-width: none !important;
    margin: clamp(36px, 8vh, 86px) auto 32px !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    color: var(--ios-ink) !important;
  }
  #login .login-blue-panel {
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    color: var(--ios-ink) !important;
  }
  #login .login-panel-heading {
    display: grid !important;
    justify-items: center;
    gap: 9px !important;
    margin: 0 0 24px !important;
    text-align: center;
  }
  #login .ios-login-stamp { display: block; object-fit: cover; border-radius: 19px; }
  #login .login-panel-title {
    margin: 0 !important;
    color: var(--ios-ink) !important;
    font: 700 26px/1.2 var(--ios-font) !important;
  }
  #login .ios-login-caption { margin: 0; font-size: 16px; color: var(--ios-muted) !important; }
  #login :is(form, #link-confirm):not([hidden]) {
    display: grid !important;
    gap: 12px !important;
    margin: 0 0 12px !important;
    padding: 16px !important;
    background: var(--ios-glass) !important;
    border: 1px solid var(--ios-line) !important;
    border-radius: 20px !important;
    box-shadow: none !important;
  }
  #login label { color: var(--ios-ink) !important; }
  #login input {
    width: 100%;
    min-height: 46px !important;
    padding: 11px 12px !important;
    border: 1px solid #ffffffbd !important;
    border-radius: 12px !important;
    color: var(--ios-ink) !important;
    background: #ffffffad !important;
    font-size: 16px !important;
  }
  #login input::placeholder { opacity: 1; color: #636875 !important; }
  #login .primary {
    min-height: 46px !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: var(--ios-lime) !important;
    color: var(--ios-ink) !important;
    box-shadow: none !important;
    font-weight: 700 !important;
  }
  #login #password-auth > .primary:disabled { background: #dff69d !important; color: #535c3d !important; }
  #login .ios-login-sync { margin: 0; line-height: 1.4; }
  #login :is(.muted, p, .login-help summary, #legacy-login summary) { color: var(--ios-muted) !important; }
  #login .login-help { padding-top: 0; border-top: 0; }
  #login .login-help a { color: #2452a7 !important; }
  #login :is(#password-login-message, #setup-message, #link-error, #login-error) { color: #9b263a !important; }

  #shell:not([hidden]), #shell .content {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    background: transparent !important;
  }
  #shell main {
    display: block !important;
    width: 100% !important;
    max-width: 720px !important;
    min-height: 100dvh;
    margin: 0 auto !important;
    padding: clamp(12px, 2.4vw, 24px) 16px calc(88px + env(safe-area-inset-bottom)) !important;
    background: transparent !important;
    overflow: visible !important;
  }
  #shell :is(.sidebar, .utility-header, .alien-header-art, .laptop-day-actions, #classic-metrics, #journal-task-advice) {
    display: none !important;
  }

  #shell .classic-masthead {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    height: auto !important;
    min-height: 0 !important;
    gap: 4px !important;
    padding: 8px 14px !important;
    margin: 0 0 12px !important;
    color: var(--ios-ink) !important;
    background: var(--ios-glass) !important;
    border: 1px solid var(--ios-line) !important;
    border-radius: 18px !important;
    box-shadow: 0 5px 20px #18243a12 !important;
    backdrop-filter: blur(20px);
  }
  #shell :is(.classic-masthead, .page-heading, #page-title)::before,
  #shell :is(.classic-masthead, .page-heading, #page-title)::after {
    content: none !important;
  }
  #shell .classic-masthead .page-heading {
    position: static !important;
    display: flex !important;
    flex-flow: row nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    min-height: 44px !important;
    height: auto !important;
    width: 100% !important;
    gap: 9px !important;
    padding: 0 !important;
    margin: 0 !important;
    grid-row: auto !important;
    grid-column: auto !important;
  }
  #shell .page-heading #page-title {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    color: var(--ios-ink) !important;
    font: 700 clamp(21px, 3.2vw, 27px)/1.2 var(--ios-font) !important;
    text-transform: none !important;
    letter-spacing: -.3px !important;
  }
  #shell #page-subtitle { display: none !important; }
  #shell .ios-header-planet { flex: 0 0 auto; object-fit: contain; }
  #shell .ios-settings {
    margin-left: auto;
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50% !important;
    background: #dff69d !important;
  }
  #shell .ios-settings img { width: 21px; height: 21px; }

  #shell #light-week-control:not([hidden]) {
    display: grid !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    max-width: none !important;
    min-width: 0 !important;
    grid-column: auto !important;
    grid-row: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    gap: 2px !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  #shell[data-page=habits] #light-week-control { display: none !important; }
  .ios-week-month {
    display: flex;
    align-items: center;
    gap: 3px;
  }
  .ios-week-month :is(strong, .ios-month-control) {
    flex: 1;
    color: var(--ios-ink);
    text-align: left;
    text-transform: capitalize;
    font-weight: 700;
  }
  #shell .ios-month-control, #shell .ios-week-month .light-week-arrow {
    min-height: 34px !important;
    padding: 4px 2px !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  #shell .ios-week-month .light-week-arrow { flex: 0 0 36px; width: 36px !important; }
  #shell .light-week-strip {
    display: grid !important;
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    gap: 3px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }
  #shell .light-week-day {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 4px 1px !important;
    color: var(--ios-ink) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 12px !important;
    box-shadow: none !important;
  }
  #shell .light-week-day[aria-pressed=true] { background: var(--ios-lime) !important; }
  #shell .light-week-day :is(small, strong) { color: var(--ios-ink) !important; }

  #shell[data-page=calendar] :is(.main-actions, #period-bar, .week-nav, #calendar-now, #month-toggle, #plan-add, #day-summary) {
    display: none !important;
  }
  #shell #calendar-view .calendar-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
    margin: 0 !important;
  }
  #shell #calendar-view .month-panel { width: 100% !important; grid-column: 1 !important; }
  #shell #calendar-view :is(.day-panel, #journal-day-aside, #day-agenda) {
    width: 100% !important;
    min-width: 0 !important;
    grid-column: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }
  #shell #calendar-view #journal-day-aside:has(#calendar-habits[hidden]) { display: none !important; }
  #shell #calendar-habits h2 { font-size: 16px !important; }
  #shell .day-panel:has(.ios-free-day) > .panel-title { display: none !important; }
  #shell .day-panel #day-title {
    margin: 0 8px 8px !important;
    color: var(--ios-muted) !important;
    font: 400 14px/1.4 var(--ios-font) !important;
  }

  #shell .ios-day-cards {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px;
  }
  #shell :is(.task-row, .agenda-card, .note-card, .habit-card, .health-metric, .month-panel, .unscheduled-section) {
    background: var(--ios-glass) !important;
    border: 1px solid var(--ios-line) !important;
    border-radius: 18px !important;
    box-shadow: 0 3px 13px #1927420a !important;
  }
  #shell :is(.task-row, .agenda-card) { color: var(--ios-ink) !important; }
  #shell :is(.task-row, .agenda-card) .task-name {
    min-width: 0 !important;
    color: var(--ios-ink) !important;
    font-weight: 600 !important;
    text-align: start !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  #shell :is(.task-row, .agenda-card) .journal-tile-icon,
  #shell .ios-day-cards .tag.todo, #shell .dense-column-head { display: none !important; }
  #shell .ios-day-cards .agenda-card {
    grid-template-columns: minmax(0, 1fr) 44px !important;
    align-items: start;
    min-height: 72px !important;
    height: auto !important;
    padding: 10px 12px !important;
    margin: 0 !important;
    gap: 4px 8px !important;
  }
  #shell .ios-day-cards .agenda-time strong {
    background: #eee8f6 !important;
    color: #773189 !important;
    border-radius: 9px;
  }
  #shell .ios-day-cards .task-row {
    grid-template-columns: 44px minmax(0, 1fr) 44px !important;
    min-height: 64px !important;
    padding: 8px 11px !important;
    margin: 0 !important;
  }
  #shell .ios-day-cards .task-row .task-row-body { display: block !important; grid-column: 2 !important; }
  #shell .ios-day-cards .task-row .task-completion { grid-column: 3 !important; grid-row: 1 !important; }
  #shell .ios-day-cards .task-row > .dense-task-date {
    grid-column: 1 !important;
    grid-row: 1 !important;
    position: static !important;
  }
  #shell .ios-day-cards .task-meta { display: flex !important; flex-wrap: wrap; gap: 4px; }
  #shell .task-completion .completion-caption { display: none !important; }
  #shell .task-completion {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
  }
  #shell .task-completion .completion-face {
    display: grid !important;
    place-items: center;
    width: 44px !important;
    height: 44px !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  #shell .task-completion .completion-mark {
    width: 24px !important;
    height: 24px !important;
    border: 1px solid #a8afbc !important;
    border-radius: 50% !important;
    background: transparent !important;
  }
  #shell .task-completion input:checked + .completion-face .completion-mark {
    border-color: #275c39 !important;
    background: #275c39 !important;
  }
  #shell .task-completion input:focus-visible + .completion-face {
    outline: 2px solid #2d5bba;
    outline-offset: 2px;
  }
  #shell[data-page=calendar] :is(.agenda-card .tag.work, .dense-task-category[data-patch=work]) {
    background: #245bd6 !important;
    color: #fff !important;
  }
  #shell .ios-day-cards .tag.family { background: #deeedf !important; color: #23583b !important; }
  #shell .ios-day-cards .ios-conflict { background: #fbe8d0 !important; color: #83410d !important; }
  #shell .ios-day-section, #shell .ios-day-empty, #shell .ios-day-completed summary {
    margin: 6px 8px !important;
    color: var(--ios-muted) !important;
    font-size: 14px !important;
  }

  #shell .ios-free-day {
    display: grid;
    justify-items: center;
    gap: 10px;
    text-align: center;
    padding: 16px 12px 8px;
  }
  #shell .ios-free-day img { object-fit: contain; }
  #shell .ios-free-day :is(h2, p) { margin: 0 !important; }
  #shell .ios-free-day h2 { font-size: 17px !important; }
  #shell .ios-free-day button {
    width: 100%;
    min-height: 44px;
    border-radius: 13px;
    background: var(--ios-glass);
  }
  #shell .ios-free-day .ios-free-primary {
    background: var(--ios-lime);
    border-color: transparent;
    color: var(--ios-ink);
    font-weight: 700;
  }

  #shell #merged-day-overdue {
    grid-column: 1 / -1 !important;
    position: static !important;
    margin: 0 0 12px !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  #shell #merged-day-overdue .ios-overdue-summary {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex !important;
    align-items: center;
    gap: 9px;
    min-height: 62px !important;
    padding: 7px 10px !important;
    border: 0 !important;
    border-radius: 12px !important;
    background: #fffdfb !important;
    color: var(--ios-ink) !important;
    cursor: pointer;
  }
  #shell .ios-overdue-summary::-webkit-details-marker { display: none; }
  #shell #merged-day-overdue .ios-overdue-summary::before {
    content: "" !important;
    position: absolute !important;
    inset: 2px !important;
    width: auto !important;
    height: auto !important;
    border: 1.5px dashed #cf3d33 !important;
    border-radius: 10px !important;
    background: transparent !important;
    pointer-events: none;
  }
  #shell #merged-day-overdue .ios-overdue-summary::after { content: none !important; }
  #shell #merged-day-overdue[open] summary { margin-bottom: 8px; }
  #shell .ios-overdue-count {
    display: grid;
    place-items: center;
    min-width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #bf352d;
    color: white;
    font-weight: 700;
  }
  #shell .ios-overdue-label { padding: 4px 6px; border-radius: 5px; background: #ffb847; font-weight: 700; }
  #shell .ios-overdue-chevron { width: 14px; height: 14px; transform: rotate(90deg); }
  #shell #merged-day-overdue[open] .ios-overdue-chevron { transform: rotate(-90deg); }
  #shell .ios-overdue-art {
    position: relative;
    flex: 0 1 63px;
    height: 46px;
    min-width: 40px;
    margin-left: auto;
    overflow: hidden;
  }
  #shell .ios-overdue-art img { position:absolute; object-fit:contain; }
  #shell .ios-overdue-planet { inset:0 10%; width:80%; height:100%; }
  #shell .ios-overdue-asteroid {
    width:23px;
    height:23px;
    right:0;
    top:0;
    animation:ios-overdue-impact 4.2s linear infinite;
  }
  @keyframes ios-overdue-impact {
    0% { transform:translate(20px,-16px); opacity:1; }
    44% { transform:translate(-5px,8px); opacity:1; }
    47%,100% { transform:translate(-5px,8px); opacity:0; }
  }
  @media(prefers-reduced-motion:reduce) {
    #shell .ios-overdue-asteroid { animation:none; }
  }

  #shell[data-page=notes] .notes-grid { grid-template-columns: minmax(0, 1fr) !important; }
  #shell[data-page=notes] .note-card {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 7px 12px !important;
    padding: 13px !important;
  }
  #shell[data-page=notes] .note-card > h3 { grid-column: 1 / -1 !important; grid-row: 1 !important; }
  #shell[data-page=notes] .note-card > .note-body { grid-column: 1 / -1 !important; grid-row: 2 !important; }
  #shell[data-page=notes] .note-card > .note-top { grid-column: 1 !important; grid-row: 3 !important; }
  #shell[data-page=notes] .note-card > .note-foot { grid-column: 2 !important; grid-row: 3 !important; }

  #shell #bottom-nav {
    position: fixed !important;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    grid-template-rows: auto !important;
    gap: 3px !important;
    inset: auto 0 calc(8px + env(safe-area-inset-bottom)) !important;
    width: calc(100% - 18px) !important;
    max-width: 490px !important;
    margin: 0 auto !important;
    padding: 4px !important;
    transform: none !important;
    border: 1px solid var(--ios-line) !important;
    border-radius: 32px !important;
    background: #f8fafbed !important;
    box-shadow: 0 5px 24px #151f3b24 !important;
    backdrop-filter: blur(18px);
    z-index: 90 !important;
  }
  #shell #bottom-nav::before, #shell #bottom-nav::after { content: none !important; }
  #shell #bottom-nav button {
    display: grid !important;
    justify-items: center;
    align-content: center;
    gap: 2px !important;
    min-width: 0 !important;
    min-height: 48px !important;
    padding: 2px !important;
    color: var(--ios-ink) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 26px !important;
    box-shadow: none !important;
  }
  #shell #bottom-nav button.active { background: #dff69d !important; }
  #shell #bottom-nav button b { font: 600 clamp(9px, 2.6vw, 12px)/1.2 var(--ios-font) !important; white-space: nowrap; }
  #shell #bottom-nav .ios-tab-icon { width: 24px !important; height: 24px !important; object-fit: contain; }

  .ios-create-menu {
    width: min(360px, calc(100% - 32px)) !important;
    border-radius: 20px !important;
    background: #f8f9fc !important;
  }
  .ios-create-menu h2 { margin: 0 0 12px; }
  .ios-create-menu button:not([hidden]) { display: block; width: 100%; min-height: 44px; margin: 4px 0; text-align: left; }
  #shell [hidden], #shell[hidden], #login[hidden], #login [hidden], .ios-create-menu [hidden] { display: none !important; }
}

@layer ios-workspace {
  #shell[data-page=tasks] #journal-task-toolbar:not([hidden]) {
    display: flex !important;
    flex-direction: column;
    gap: 8px !important;
    margin: 0 0 12px !important;
    padding: 0 !important;
  }
  #shell[data-page=tasks] #journal-task-toolbar .main-actions,
  #shell[data-page=tasks] .classic-categories { display: none !important; }
  #shell[data-page=tasks] #classic-task-tools {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 0 !important;
  }
  #shell :is(#classic-task-search, #notes-search) {
    width: 100% !important;
    min-height: 44px !important;
    padding: 8px 12px !important;
    background: var(--ios-glass) !important;
    border: 1px solid var(--ios-line) !important;
    border-radius: 13px !important;
  }
  #shell :is(#light-task-filter, .ios-status-filters, .notes-chips) {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px !important;
    margin: 0 0 6px !important;
  }
  #shell :is(#light-task-filter, .ios-status-filters, .notes-chips) button, #shell #notes-pinned {
    min-height: 38px !important;
    padding: 5px 10px !important;
    border: 1px solid var(--ios-line) !important;
    border-radius: 10px !important;
    background: var(--ios-glass) !important;
    color: var(--ios-ink) !important;
    box-shadow: none !important;
  }
  #shell :is(#light-task-filter, .ios-status-filters, .notes-chips) button[aria-pressed=true],
  #shell #notes-pinned[aria-pressed=true] {
    background: #dff69d !important;
    border-color: #c3d886 !important;
  }
  #shell .ios-status-filters [data-habit-status=active][aria-pressed=true] {
    background: #255d3c !important;
    color: white !important;
  }
  #shell[data-page=notes] :is(#items,.notes-grid) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    gap: 8px !important;
  }
  #shell[data-page=notes] #note-controls {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
  }
  #shell[data-page=notes] #note-controls .notes-search-label { order: 4; width: 100%; }
  #shell[data-page=notes] .note-card .note-body {
    white-space: pre-wrap !important;
    overflow-wrap: anywhere;
    display: -webkit-box !important;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden !important;
    max-height: none !important;
  }
  #shell[data-page=notes] .note-card .dense-note-open { text-align: start !important; }
  #shell[data-page=habits] #habit-list { display: grid !important; grid-template-columns: minmax(0, 1fr) !important; gap: 8px !important; }
  #shell[data-page=habits] .habit-card {
    border-inline-start: 3px solid #28704b !important;
    background: #e8f3e9dc !important;
  }
  #shell[data-page=habits] .habit-card.habit-done { background: #edf6d8 !important; }
  #shell .habit-card progress { accent-color: #2e6c4a; }
  #shell .habit-count { color: #425f50 !important; }

  #shell #fitness-view #health-daily-cards {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)) !important;
    gap: 8px !important;
  }
  #shell #fitness-view .health-daily {
    display: block !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }
  #shell #fitness-view :is(.fitness-hero,.body-panel,.fitness-advice,.health-daily .health-metric,.health-quick-links button,#desktop-recovery) {
    background: var(--ios-glass) !important;
    border: 1px solid var(--ios-line) !important;
    border-radius: 18px !important;
    box-shadow: 0 3px 13px #1927420a !important;
  }
  #shell #fitness-view #desktop-recovery {
    display: block !important;
    color: #21583a;
    min-height: 0 !important;
    margin: 8px 0 !important;
  }
  #shell .health-quick-links .ios-fitness-weight { object-fit: contain; flex: 0 0 24px; }
  #shell #fitness-view :is(.health-daily,.fitness-advice,.body-panel) h2 { color: var(--ios-ink) !important; }

  :is(#task-dialog,#note-dialog,#habit-dialog,#assistant-dialog,#settings-dialog,#filter-dialog,#fitness-dialog) {
    background: #f2f2f7 !important;
    color: var(--ios-ink) !important;
    border: 1px solid var(--ios-line) !important;
    border-radius: 22px !important;
    font-family: var(--ios-font) !important;
  }
  :is(#task-dialog,#note-dialog,#habit-dialog,#assistant-dialog,#settings-dialog,#filter-dialog,#fitness-dialog)::backdrop {
    background: rgb(17 24 39 / .3);
  }
  :is(#task-dialog,#note-dialog,#habit-dialog,#assistant-dialog,#settings-dialog,#filter-dialog,#fitness-dialog) :is(.panel-title,.assistant-header) {
    background: transparent !important;
    color: var(--ios-ink) !important;
    border-bottom: 1px solid #dae0ee !important;
  }
  :is(#task-dialog,#note-dialog,#habit-dialog,#assistant-dialog,#settings-dialog,#filter-dialog,#fitness-dialog) :is(h2,h3) {
    color: var(--ios-ink) !important;
    font-family: var(--ios-font) !important;
  }
  :is(#task-dialog,#note-dialog,#habit-dialog,#assistant-dialog,#settings-dialog,#filter-dialog,#fitness-dialog) .primary {
    background: var(--ios-lime) !important;
    color: var(--ios-ink) !important;
    border: 1px solid transparent !important;
    border-radius: 13px !important;
    box-shadow: none !important;
  }
  :is(#task-dialog,#note-dialog,#habit-dialog,#filter-dialog) :is(input:not([type=checkbox]),select,textarea) {
    background: #fff !important;
    color: var(--ios-ink) !important;
    border: 1px solid #dbe1ea !important;
    border-radius: 12px !important;
    font-size: 16px !important;
  }
  #filter-dialog #task-controls .ios-check-filter { display: flex !important; align-items: center; }
  #filter-dialog #include-completed { width: 18px; height: 18px; accent-color: #326348; }
  #note-dialog [name=body] { min-height: 180px; }
  #assistant-dialog #assistant-title { display: flex !important; align-items: center; gap: 8px; }
  #assistant-dialog .ios-qwen-avatar { object-fit: contain; border-radius: 50%; }
  #assistant-dialog .chat-message.user { background: #e1f2b9 !important; color: var(--ios-ink) !important; }
  #assistant-dialog :is(.chat-message.assistant,.assistant-draft) { background: white !important; color: var(--ios-ink) !important; }
  #settings-dialog .settings-list button:not([hidden]) { background: white !important; color: var(--ios-ink) !important; border-radius: 12px !important; }
  #shell #light-task-filter[hidden], #shell #note-controls[hidden] { display: none !important; }

  @media (max-width: 600px) {
    :is(#note-dialog,#assistant-dialog) { border-radius: 0 !important; }
    #shell #fitness-view #health-daily-cards { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  }
}

@layer ios-workspace {
  #shell:is([data-page=habits],[data-page=notes]) .main-actions { display: none !important; }
  #shell .habit-view-switch button[aria-pressed=true] { color: var(--ios-ink) !important; background: #dff69d !important; }
  #shell .habit-card progress::-webkit-progress-value { background: #2e6c4a !important; }

  #shell #fitness-view .health-daily {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  #shell #fitness-view .health-daily > :is(.panel-title, #health-daily-status, [data-health-panel=activity]) {
    grid-column: 1 / -1 !important;
  }
  #shell #fitness-view .health-daily > .panel-title { order: -2 !important; }
  #shell #fitness-view .health-daily > [data-health-panel=activity] { order: 8 !important; }
  #shell #fitness-view #health-daily-cards { display: contents !important; }
  #shell #fitness-view #health-daily-cards .health-metric {
    grid-column: auto !important;
    order: 3 !important;
    min-height: 100px !important;
  }
  #shell #fitness-view #health-daily-cards [data-metric=sleep_minutes] { order: 0 !important; }
  #shell #fitness-view #health-daily-cards [data-metric=steps] { order: 1 !important; }
  #shell #fitness-view #desktop-recovery {
    grid-column: auto !important;
    order: 2 !important;
    margin: 0 !important;
  }
  #shell #fitness-view #health-daily-status { order: 9 !important; }

  @media (max-width: 600px) {
    :is(#note-dialog,#assistant-dialog) {
      max-width: 100% !important;
      overflow-x: hidden !important;
    }
  }
}

@layer ios-workspace {
  #shell #fitness-view .health-daily > .fitness-advice {
    grid-column: 1 / -1 !important;
    order: 7 !important;
  }
  #shell #fitness-view .health-quick-links {
    display: grid !important;
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    gap: 8px !important;
  }
  #shell #fitness-view .health-quick-links button {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
}

@layer ios-workspace {
  html { scrollbar-gutter: auto !important; }
  #shell .ios-dock {
    position: fixed;
    inset: auto max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 490px;
    margin-inline: auto;
    z-index: 90;
  }
  #shell .ios-dock #bottom-nav {
    position: static !important;
    inset: auto !important;
    width: auto !important;
    flex: 1 1 0;
    min-width: 0;
    grid-template-columns: repeat(5,minmax(0,1fr)) !important;
    margin: 0 !important;
  }
  #shell .ios-dock .ios-add {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    padding: 0 !important;
    border: 1px solid var(--ios-line) !important;
    border-radius: 50% !important;
    background: #f6f8f0 !important;
    box-shadow: 0 5px 17px #151f3b24;
  }
  #shell .ios-dock .ios-add img { width: 23px; height: 23px; }
  #shell .classic-masthead { position: sticky !important; top: env(safe-area-inset-top); z-index: 20; }

  #shell #light-task-filter {
    display: grid !important;
    grid-template-columns: auto minmax(0,1fr) auto !important;
    width: 100%;
  }
  #shell #light-task-filter[hidden] { display: none !important; }
  #shell #light-task-filter button { width: auto !important; font-size: 13px !important; }
  #shell #light-task-filter [data-light-period=day] { background:#245bd6 !important; color:white !important; }
  #shell #light-task-filter [data-light-period=overdue] { background:#18233c !important; color:white !important; }
  #shell #light-task-filter [aria-pressed=true] { outline: 2px solid #759829; outline-offset: 1px; }
  #shell :is(#active-filter-summary,#list-count) { color:#505a68 !important; }
  #shell[data-page=tasks] #list-section > .panel-title h2,
  #shell[data-page=notes] #list-section > .panel-title h2 { display:none !important; }
  #shell[data-page=notes] #notes-pinned { order: 1; }
  #shell[data-page=notes] #note-controls .notes-search-label { order: 2; }
  #shell[data-page=notes] #note-controls > label:has(#note-filter) { order: 3; }
  #shell[data-page=notes] .note-card { position: relative; padding: 11px!important; }
  #shell[data-page=notes] .dense-note-open::after { content: ""; position: absolute; inset: 0; }
  #shell[data-page=notes] .note-foot { position: relative; }
  #shell[data-page=habits] #habit-summary:not([hidden]) { display:none !important; }
  #shell #habit-list .habit-card { width: 100% !important; }
  #shell .ios-free-day .ios-free-primary { background:var(--ios-lime) !important; }
  #shell .ios-free-day button:not(.ios-free-primary) { background:#e1e4eb !important; }
  #shell .ios-free-day button { border-radius:999px !important; }

  :is(#task-dialog,#note-dialog,#habit-dialog,#filter-dialog) :is(form > .panel-title, .task-editor-heading) {
    position: sticky !important;
    top: 0;
    z-index: 4;
    display: flex !important;
    gap: 8px !important;
    align-items: center;
    padding: 8px 0 !important;
    background: #f2f2f7 !important;
  }
  :is(#task-dialog,#note-dialog,#habit-dialog,#filter-dialog) .panel-title h2 { flex: 1; font-size: clamp(16px,3.9vw,20px)!important; }
  :is(#task-dialog,#note-dialog,#habit-dialog,#filter-dialog) .panel-title .ios-header-save {
    min-height: 40px;
    flex: 0 0 auto;
    padding: 7px 10px !important;
    margin: 0 !important;
    font-size: 13px !important;
    border-radius: 999px !important;
  }
  :is(#task-dialog,#note-dialog,#habit-dialog,#filter-dialog) .panel-title button:not(.ios-header-save) { order: -1; }
  :is(#task-dialog,#note-dialog,#habit-dialog,#filter-dialog) .dialog-actions:empty { display:none !important; }
  :is(#task-dialog,#filter-dialog,#assistant-dialog,#assistant-data-dialog) [hidden] { display:none !important; }
  :is(#task-form,#filter-form,#habit-form,#note-form) :is(.ios-switch-row,.ios-priority label,.ios-check-filter,.ios-switch-list label,.checks label):not([hidden]) {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    flex-direction: row-reverse;
    gap: 12px !important;
    min-height: 44px;
  }
  :is(#task-form,#filter-form,#habit-form,#note-form) :is(.ios-switch-row,.ios-priority,.ios-check-filter,.ios-switch-list,.checks) input[type=checkbox] {
    appearance:none; width:42px!important; height:25px!important; flex:0 0 42px;
    border:0!important; border-radius:999px!important; background:#a9b1be!important;
    position:relative;cursor:pointer;
  }
  :is(#task-form,#filter-form,#habit-form,#note-form) :is(.ios-switch-row,.ios-priority,.ios-check-filter,.ios-switch-list,.checks) input[type=checkbox]::before {
    content:"";position:absolute;width:19px;height:19px;top:3px;left:3px;background:#fff;border-radius:50%;
  }
  :is(#task-form,#filter-form,#habit-form,#note-form) :is(.ios-switch-row,.ios-priority,.ios-check-filter,.ios-switch-list,.checks) input[type=checkbox]:checked { background:#27714a!important; }
  :is(#task-form,#filter-form,#habit-form,#note-form) :is(.ios-switch-row,.ios-priority,.ios-check-filter,.ios-switch-list,.checks) input[type=checkbox]:checked::before { left:20px; }
  #habit-form .ios-switch-list { display:grid!important; grid-template-columns: minmax(0,1fr)!important; gap:0!important; }
  #habit-form .ios-switch-list label { margin:0!important; padding:6px 10px!important; border-bottom:1px solid #e2e5eb; }
  #habit-form .ios-switch-list label:last-child { border-bottom:0; }
  #habit-form .ios-switch-list,#task-form .task-priorities { background:#fff; border-radius:12px; }
  #task-form .task-priorities { display:grid!important; padding:0 10px; }
  #task-dialog.focus-new-task:not(.focus-task-expanded) .task-priorities { display:none!important; }
  .ios-stepper:not([hidden]) { display:grid; grid-template-columns:minmax(0,1fr) auto auto; align-items:end; gap:5px; min-width:0; }
  .ios-stepper label { margin-bottom:0!important; }
  .ios-stepper button { min-width:32px; min-height:36px; padding:2px!important; }
  #task-planning .ios-stepper { grid-column:1 / -1; }
  #filter-form .ios-priority { border:1px solid #dbe1ea;border-radius:12px;margin:0; }
  #note-dialog #note-form [name=body] { border-color:transparent!important;background:transparent!important; }
  #note-dialog #note-form [name=title] { font-size:22px!important;border-color:transparent!important;background:transparent!important; }
  #note-dialog #note-save-status { font-size:10px!important; }

  :is(.ios-detail-dialog,.ios-create-menu,#assistant-data-dialog,#archive-confirm,#light-measurement-dialog,#install-dialog,#telegram-dialog,#account-dialog,#invite-dialog,#trash-dialog,#push-dialog,#light-search-dialog) {
    max-width: min(540px,calc(100% - 20px)) !important;
    background:#f2f2f7 !important;
    border:1px solid var(--ios-line) !important;
    border-radius:22px !important;
    color:var(--ios-ink) !important;
    font-family:var(--ios-font) !important;
    margin:auto !important;
    padding:16px !important;
  }
  :is(.ios-detail-dialog,#assistant-data-dialog,#light-measurement-dialog,#install-dialog,#telegram-dialog,#account-dialog,#invite-dialog,#trash-dialog,#push-dialog,#light-search-dialog) :is(h2,button,label,p,summary) {
    font-family:var(--ios-font) !important;
  }
  :is(#light-measurement-dialog,#telegram-dialog,#account-dialog,#invite-dialog,#push-dialog) .primary {
    background: var(--ios-lime) !important;
    color: var(--ios-ink) !important;
    border-color: transparent !important;
    box-shadow:none !important;
  }
  #shell .ios-detail-dialog { position:fixed!important; inset:0!important; width:min(540px,calc(100% - 20px)); }
  .ios-detail-dialog > header,#assistant-data-dialog > header { display:flex; justify-content:space-between;align-items:center;gap:12px; }
  .ios-detail-dialog > header h2,#assistant-data-dialog > header h2 { font-size:20px!important; }
  .ios-detail-content .desktop-recovery-detail { display:grid; gap:8px; }
  .desktop-recovery-detail > section { background:white;padding:12px;border-radius:14px; }
  .desktop-recovery-detail :is(h3,p) { margin:0 0 6px; }
  .desktop-recovery-detail p:last-child { margin-bottom:0; }
  #shell #desktop-recovery .ios-recovery-open {
    display:grid !important; justify-items:start;align-content:start;gap:4px;
    width:100%;height:100%;min-height:92px; padding:8px!important;border:0!important;background:transparent!important;text-align:left;overflow-wrap:anywhere;
  }
  #shell #desktop-recovery .ios-recovery-open :is(span,strong) { font-size:clamp(10px,3vw,14px)!important; }
  #shell #fitness-view :is(#health-daily-cards .health-metric,.ios-detail-dialog .light-body-metric) {
    height:auto!important; min-height:92px!important; grid-template-rows:auto auto auto auto!important; row-gap:3px!important;
  }
  #shell #fitness-view :is(#health-daily-cards .health-metric,.ios-detail-dialog .light-body-metric) .metric-info {
    font-size:11px!important; line-height:1.2;
  }
  #shell #fitness-view .ios-fitness-hours { grid-column:1 / -1; order:4!important; background:var(--ios-glass)!important;border-radius:18px!important; }
  #shell .ios-fitness-hours > h2 { font-size:16px!important; }
  #shell .ios-detail-dialog .body-panel { margin:0 !important; }
  #shell .ios-detail-dialog .light-weight-chart { display:block!important; margin-top:12px!important; }
  #shell .ios-detail-dialog .light-weight-chart > .panel-title { display:grid!important; gap:6px!important; }
  #shell .ios-detail-dialog .body-panel > .panel-title { flex-wrap:wrap!important; }

  #assistant-dialog .assistant-header { display:flex !important; align-items:center; gap:6px; }
  #assistant-dialog #assistant-close { order:-1; flex:0 0 auto; }
  #assistant-dialog #assistant-title { justify-content:center; }
  #assistant-dialog .assistant-header > div { flex:1; }
  #assistant-dialog :is(#assistant-chat-settings,.ios-assistant-actions) { font-size:12px!important; min-height:38px; }
  #assistant-dialog .ios-assistant-welcome { padding:14px;margin:8px 0;background:white;border-radius:16px; }
  #assistant-dialog .ios-assistant-welcome h3 { margin:0 0 6px; }
  #assistant-data-controls { display:grid; gap:10px; padding:10px 0; }
  #settings-dialog .ios-settings-extra { margin-top:8px; }
  #settings-dialog .ios-settings-extra > summary { min-height:44px; cursor:pointer; padding:10px; }
  #settings-dialog .settings-list #settings-logout { color:#9c2539!important; }
  #assistant-dialog #assistant-welcome[hidden] { display:none!important; }
  #assistant-dialog #assistant-welcome img { object-fit:contain; vertical-align:middle; }

  @media(max-width:600px) {
    :is(#task-dialog,#habit-dialog,#filter-dialog,#settings-dialog,#assistant-data-dialog) {
      position:fixed!important;
      inset:auto 0 0!important;
      width:100%!important;
      max-width:100%!important;
      max-height:calc(100dvh - max(12px, env(safe-area-inset-top)))!important;
      margin:0 auto!important;
      padding-bottom:max(16px,env(safe-area-inset-bottom))!important;
      border-radius:22px 22px 0 0!important;
    }
    #shell .ios-detail-dialog {
      inset:max(0px,env(safe-area-inset-top)) 0 0!important;
      width:100%!important;
      max-width:100%!important;
      height:auto!important;
      max-height:none!important;
      margin:0!important;
      border-radius:0!important;
      padding-bottom:max(16px,env(safe-area-inset-bottom))!important;
    }
  }
}
