/* LifeTracker 1.4.29 — one responsive layer for laptop, tablet and small windows. */
html,body,#app,.app-shell,.main,.view,#view{min-width:0!important;max-width:100%!important}
html,body{overflow-x:hidden!important}
.main,.view,#view,.view>*{min-width:0!important}
img,svg,video,canvas{max-width:100%}
input,select,textarea,button{max-width:100%}
.card,.panel,.settings-panel-v129,.finance-panel-v127,.analytics-panel-v140,
.memory-command-hero-v1420,.memory-main,.memory-paper,.telegram-inspector{min-width:0!important}
.topbar>div,.card-head>div,.panel-head>div,.finance-panel-head-v127>div,
.analytics-panel-title-v140>div,.settings-head-v129>div{min-width:0}
.topbar h1,.card-head h2,.panel-head h2,.finance-panel-head-v127 h2,
.settings-head-v129 h2{overflow-wrap:anywhere}

/* Desktop and laptop shell: the sidebar now gives space back to content. */
@media (min-width:921px){
  #app.app-shell,.app-shell{
    grid-template-columns:clamp(220px,18vw,284px) minmax(0,1fr)!important;
  }
  .sidebar{
    width:auto!important;max-width:none!important;
    padding:clamp(16px,1.55vw,24px) clamp(12px,1.2vw,18px)!important;
    padding-bottom:max(30px,env(safe-area-inset-bottom))!important;
    gap:clamp(12px,1.25vw,20px)!important;
    height:100dvh!important;
    max-height:100dvh!important;
    scroll-padding-bottom:max(30px,env(safe-area-inset-bottom))!important;
    scrollbar-gutter:stable!important;
  }
  .sidebar-bottom{padding-bottom:8px!important}
  .main{padding:clamp(18px,2.25vw,38px)!important}
}
@media (min-width:921px) and (max-width:1280px){
  #app.app-shell,.app-shell{grid-template-columns:220px minmax(0,1fr)!important}
  .brand{gap:9px!important;padding-inline:2px!important}
  .brand-mark{width:39px!important;height:39px!important;flex:0 0 39px!important}
  .brand-title{font-size:16px!important}
  .brand-subtitle{font-size:10px!important}
  #nav{gap:7px!important}
  #nav button{min-height:48px!important;padding:9px 11px!important;font-size:14px!important}
  .side-card{padding:13px!important}
  .main{padding:20px!important}
  .topbar{margin-bottom:18px!important}
}

/* Compact navigation instead of a full-height second page above the content. */
@media (max-width:920px){
  html,body{height:auto!important;overflow:auto!important}
  #app.app-shell,.app-shell{display:block!important;width:100%!important;min-height:100vh!important}
  .sidebar{
    position:relative!important;top:auto!important;width:100%!important;height:auto!important;
    min-height:0!important;padding:12px 14px!important;gap:10px!important;
    border-right:0!important;border-bottom:1px solid var(--line)!important;
    padding-bottom:max(18px,env(safe-area-inset-bottom))!important;
  }
  .brand{padding:3px 3px 10px!important}
  .brand-mark{width:38px!important;height:38px!important;flex:0 0 38px!important}
  .brand-title{font-size:16px!important}.brand-subtitle{font-size:10px!important}
  #nav,.nav{
    display:grid!important;grid-template-columns:repeat(6,minmax(0,1fr))!important;
    gap:6px!important;width:100%!important;overflow:visible!important;
  }
  #nav button{
    display:grid!important;grid-template-columns:1fr!important;place-items:center!important;
    gap:2px!important;width:100%!important;min-width:0!important;min-height:54px!important;
    padding:6px 4px!important;text-align:center!important;font-size:11px!important;line-height:1.15!important;
  }
  #nav button span{font-size:18px!important}
  .side-card{display:none!important}
  .sidebar-bottom{
    display:grid!important;grid-template-columns:minmax(0,1fr) repeat(2,minmax(120px,auto))!important;
    gap:7px!important;margin:0!important;
  }
  .sidebar-bottom>.save-indicator-v499{order:0!important;min-width:0!important}
  .sidebar-bottom>button{min-width:0!important;min-height:38px!important;padding:7px 10px!important}
  .main{display:block!important;width:100%!important;padding:16px!important}
}
@media (max-width:640px){
  #nav,.nav{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .sidebar-bottom{grid-template-columns:1fr 1fr!important}
  .sidebar-bottom>.save-indicator-v499{grid-column:1/-1!important}
  .main{padding:12px!important}
  .topbar{align-items:flex-start!important;gap:10px!important}
  .topbar h1{font-size:clamp(28px,9vw,40px)!important}
}
@media (max-width:390px){
  #nav,.nav{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .sidebar-bottom{grid-template-columns:1fr!important}
  .sidebar-bottom>.save-indicator-v499{grid-column:auto!important}
}

/* Common responsive rows, toolbars and cards. */
@media (max-width:1180px){
  .grid.three,.grid.four{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .finance-command-v127,.finance-hero-v127,.card-head,.panel-head{
    flex-wrap:wrap!important;
  }
  .finance-command-v127 nav,.finance-periods-v127,.analytics-periods-v140{
    max-width:100%!important;overflow-x:auto!important;overscroll-behavior-x:contain!important;
  }
  .finance-layout-v127,.analytics-finance-v140{grid-template-columns:1fr!important}
  .goal-progress-box-v493{grid-template-columns:1fr!important}
  .goal-kind-cards-v491,.goal-kind-cards-v493,.goal-kind-cards-v499{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
  .goal-fields-grid-v493{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}
@media (max-width:720px){
  .grid.two,.grid.three,.grid.four,.finance-kpis-v127,.finance-side-v127,
  .finance-plan-grid-v127,.finance-budget-grid-v127,.analytics-grid-v140.two,
  .settings-dashboard-v129,.settings-shortcuts-v129{
    grid-template-columns:1fr!important;
  }
  .card,.finance-panel-v127,.analytics-panel-v140{padding:15px!important;border-radius:18px!important}
  .card-head,.panel-head,.finance-panel-head-v127,.analytics-panel-title-v140{
    align-items:flex-start!important;gap:10px!important;
  }
  .finance-tools-v127,.finance-quick-v127{display:grid!important;grid-template-columns:1fr!important;width:100%!important}
  .finance-tools-v127 input,.finance-tools-v127 select,.finance-quick-v127 button{width:100%!important}
  .finance-row-v127{grid-template-columns:38px minmax(0,1fr) auto!important}
  .finance-row-actions-v127{grid-column:2/-1!important;grid-row:auto!important;justify-content:flex-start!important;flex-wrap:wrap!important}
  .goal-kind-cards-v491,.goal-kind-cards-v493,.goal-kind-cards-v499,
  .goal-fields-grid-v493,.goal-progress-settings-v491,.goal-date-grid-v491{
    grid-template-columns:1fr!important;
  }
}

/* Settings: stable sidebar and controls that never cover their labels. */
@media (max-width:1050px){
  .settings-app-v129{grid-template-columns:1fr!important;gap:14px!important}
  .settings-sidebar-v129{position:static!important;padding:10px!important;border-radius:20px!important}
  .settings-brand-v129{padding-bottom:10px!important}
  .settings-sidebar-v129 nav{
    display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:6px!important;
  }
  .settings-sidebar-v129 nav button{
    display:grid!important;grid-template-columns:32px minmax(0,1fr)!important;
    gap:7px!important;min-width:0!important;padding:6px!important;font-size:11px!important;
  }
  .settings-sidebar-v129 nav button i{width:30px!important;height:30px!important}
  .settings-saved-v129{display:none!important}
}
@media (max-width:700px){
  .settings-sidebar-v129 nav{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .settings-head-v129{align-items:flex-start!important;gap:12px!important}
  .settings-head-icon-v129{width:48px!important;height:48px!important;border-radius:15px!important;font-size:23px!important}
  .settings-head-v129 h2{font-size:25px!important}
  .setting-row-v129{
    grid-template-columns:38px minmax(0,1fr)!important;align-items:start!important;
    gap:10px!important;padding:12px 14px!important;
  }
  .setting-row-v129>select,.setting-row-v129>em,.setting-row-v129>.accent-swatches-v129,
  .setting-row-v129>input:not([type=checkbox]){
    grid-column:1/-1!important;width:100%!important;min-width:0!important;
  }
  .accent-swatches-v129{flex-wrap:wrap!important}
  .settings-tip-v129{display:grid!important;grid-template-columns:auto minmax(0,1fr)!important}
  .settings-tip-v129 button{grid-column:1/-1!important;width:100%!important;margin:0!important}
}

/* Notes centre and editor. */
@media (max-width:1200px){
  .memory-app{grid-template-columns:190px minmax(0,1fr)!important}
  .memory-command-hero-v1420{grid-template-columns:1fr!important}
  .memory-command-hero-copy,.memory-command-primary-actions{grid-column:1!important;min-width:0!important}
  .memory-command-primary-actions{justify-content:flex-start!important;flex-wrap:wrap!important}
  .memory-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .telegram-editor .memory-editor-shell.memory-editor-two-column,
  .telegram-editor .memory-editor-shell.memory-editor-two-column.density-compact{
    grid-template-columns:minmax(0,1fr) 240px!important;
  }
  .memory-editor-two-column .memory-paper{padding:28px clamp(24px,4vw,54px) 42px!important}
}
@media (max-width:980px){
  .memory-app{grid-template-columns:1fr!important}
  .memory-sidebar{position:static!important;max-height:none!important}
  .memory-sidebar nav{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .telegram-editor .memory-editor-shell.memory-editor-two-column,
  .telegram-editor .memory-editor-shell.memory-editor-two-column.density-compact{grid-template-columns:1fr!important}
  .memory-editor-two-column .telegram-inspector{
    grid-column:1!important;position:static!important;max-height:none!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
}
@media (max-width:620px){
  .memory-sidebar nav,.memory-grid,.memory-template-grid,.memory-all-files,
  .memory-editor-two-column .telegram-inspector{grid-template-columns:1fr!important}
  .memory-command-primary-actions{display:grid!important;grid-template-columns:1fr!important;width:100%!important}
  .memory-command-primary-actions button{width:100%!important}
  .memory-command-hero-copy{min-width:0!important}
  .memory-toolbar{align-items:stretch!important}
  .memory-toolbar>*{width:100%!important;max-width:none!important}
  .telegram-editor-head{display:grid!important;grid-template-columns:auto minmax(0,1fr) auto!important}
  .telegram-editor-head>div:last-child{grid-column:1/-1!important;display:grid!important;grid-template-columns:1fr 1fr!important;width:100%!important}
  .telegram-editor-head>div:last-child button{width:100%!important}
  .telegram-format-bar{max-width:100%!important;overflow:auto!important}
  .memory-editor-two-column .memory-paper{padding:20px 16px 32px!important;min-height:480px!important}
}

/* Month keeps all task names and scrolls only inside the matrix. */
.month-main-card,.month-main-card .matrix-wrap{min-width:0!important;max-width:100%!important}
.month-main-card .matrix-wrap{
  overflow:auto!important;
  overscroll-behavior-x:contain!important;
  overscroll-behavior-y:auto!important;
}
.month-controls,.month-filters{max-width:100%!important;flex-wrap:wrap!important}
@media (max-width:720px){
  .month-main-card{padding:10px!important}
  .month-main-card .matrix thead th:first-child,
  .month-main-card .matrix tbody td:first-child{
    min-width:148px!important;width:148px!important;max-width:148px!important;
  }
  .month-task-overlay-v145,.month-task-overlay-v145>div{width:148px!important}
}

/* Dialogs and floating menus stay inside the current viewport. */
dialog.modal,.modal,.goal-modal-v491{
  max-width:calc(100vw - 24px)!important;max-height:calc(100dvh - 24px)!important;
}
.modal>form,.goal-modal-v491 #modalForm{max-height:calc(100dvh - 24px)!important}
.modal-body{min-width:0!important;overflow:auto!important}
.month-action-menu-v110,.telegram-slash-menu,.color-palette,
.memory-explanation-popover{max-width:calc(100vw - 20px)!important}
@media (max-width:560px){
  dialog.modal,.modal,.goal-modal-v491{width:calc(100vw - 12px)!important;max-width:calc(100vw - 12px)!important}
  .modal-head,.modal-actions{padding-inline:14px!important}
  .modal-body{padding:14px!important}
  .modal-actions{display:grid!important;grid-template-columns:1fr!important}
  .modal-actions button{width:100%!important}
  .memory-explanation-composer footer{grid-template-columns:1fr 1fr!important}
}

/* Prevent long user content from expanding a card beyond the window. */
.habit-item,.task-row,.extra-setting-row,.backup-row,.memory-card,.goal-card,
.goal-v421-card,.goal-v422-card,.action-history-row-v499{min-width:0!important}
.habit-item b,.habit-item span,.task-row b,.task-row span,.memory-card h3,
.memory-card p,.backup-main b,.backup-main span{overflow-wrap:anywhere}

/* Task settings respond to the card width, not to the full desktop window. */
.task-settings-group{
  container-name:task-settings;
  container-type:inline-size;
  width:100%;
  min-width:0;
  max-width:100%;
}
.task-settings-group .task-row-v486{
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
}
@container task-settings (max-width:1100px){
  .task-settings-group .task-row-v486{
    grid-template-columns:minmax(180px,1.35fr) minmax(150px,1fr) minmax(120px,.72fr) minmax(180px,1fr)!important;
  }
  .task-settings-group .task-actions-v486{
    grid-column:1/-1!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    width:100%!important;
  }
}
@container task-settings (max-width:720px){
  .task-settings-group .task-row-v486{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
}
@container task-settings (max-width:440px){
  .task-settings-group .task-row-v486{
    grid-template-columns:minmax(0,1fr)!important;
  }
  .task-settings-group .task-actions-v486{
    grid-template-columns:minmax(0,1fr)!important;
  }
}
