/* Backup and Appearance apps. These utility screens intentionally live in
   their own stylesheet so feature UI never leaks into chat or journal CSS. */

.desktop-layout {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 14px 10px !important;
  height: auto !important;
  min-height: 145px;
  padding: 4px 2px 10px;
}
.pages { width: 300% !important; }
.page { width: 33.333333% !important; }
.apps-page {
  padding-top: clamp(30px, 7vh, 64px) !important;
  color: #292927;
}
.desktop-layout-extra {
  width: min(100%, 350px);
  min-height: 0;
  margin: 0 auto !important;
  padding: 0 8px 18px;
  align-content: start;
  align-items: start;
  gap: 28px 16px !important;
}
.desktop-layout-extra .app-item {
  min-width: 0;
  justify-self: center;
}
.desktop-layout-extra .app-icon {
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 17px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 8px 24px rgba(35,35,31,.065);
}
.desktop-layout-extra .app-icon svg { width: 21px; height: 21px; }
.desktop-layout-extra .app-label {
  width: auto;
  max-width: 84px;
  margin-top: 8px;
  color: #555550;
  font-size: 8px;
  line-height: 1.35;
  white-space: normal;
}
.desktop-layout .app-item {
  position: static !important;
  width: auto !important;
  transform: none !important;
}

@media (max-width: 360px), (max-height: 680px) {
  .apps-page { padding-top: 24px !important; }
  .desktop-layout-extra { gap: 22px 10px !important; padding-right: 2px; padding-left: 2px; }
  .desktop-layout-extra .app-icon { width: 50px; height: 50px; border-radius: 16px; }
}

@media (min-width: 431px) and (max-width: 1366px) and (pointer: coarse),
       (min-width: 431px) and (max-width: 1366px) and (hover: none) {
  .apps-page { padding-top: clamp(46px, 8vh, 84px) !important; }
  .desktop-layout-extra { width: min(100%, 520px); gap: 38px 34px !important; }
  .desktop-layout-extra .app-icon { width: 62px; height: 62px; border-radius: 19px; }
}

.app-modal:has(.utility-app:not([hidden])) .modal-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #f7f7f5;
  text-align: left;
}

.app-modal:has(.utility-app:not([hidden])) .modal-close { flex: 0 0 auto; }

.utility-app {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 2px calc(30px + env(safe-area-inset-bottom));
  color: #292927;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.utility-app-head { display: flex; align-items: end; justify-content: space-between; gap: 14px; padding: 4px 2px 14px; border-bottom: 1px solid #deded9; }
.utility-app-head small { display: block; margin-bottom: 4px; color: #999; font-size: 8px; letter-spacing: .16em; }
.utility-app-head strong { display: block; font: 600 22px/1.1 var(--display-font); }
.utility-app-head > span { color: #8a8a86; font-size: 9px; }
.utility-intro { margin: 12px 2px 16px; color: #6e6e69; font-size: 10px; line-height: 1.65; }

.utility-card { margin: 0 0 12px; padding: 15px; border: 1px solid #e2e2de; border-radius: 16px; background: #fff; box-shadow: 0 6px 22px rgba(35,35,30,.035); }
.utility-card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.utility-card-title strong, .beauty-editor-heading strong { display: block; font-size: 12px; }
.utility-card-title small, .beauty-editor-heading small { display: block; margin-top: 3px; color: #999; font-size: 8px; line-height: 1.45; }
.utility-card-title > button, .beauty-editor-heading > button { min-height: 28px; padding: 0 10px; border: 1px solid #deded9; border-radius: 14px; background: #f8f8f6; font-size: 8px; }

.backup-app-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.backup-choice { position: relative; display: flex; align-items: center; gap: 9px; min-height: 43px; padding: 9px 10px; border: 1px solid #e7e7e3; border-radius: 11px; background: #fafaf8; }
.backup-choice input { position: absolute; opacity: 0; pointer-events: none; }
.backup-choice i { width: 16px; height: 16px; flex: 0 0 auto; border: 1px solid #bdbdb8; border-radius: 5px; background: #fff; }
.backup-choice input:checked + i { border-color: #292927; background: #292927; box-shadow: inset 0 0 0 3px #fff; }
.backup-choice span { min-width: 0; }
.backup-choice strong, .backup-choice small { display: block; }
.backup-choice strong { font-size: 9px; }
.backup-choice small { margin-top: 2px; overflow: hidden; color: #999; font-size: 7px; text-overflow: ellipsis; white-space: nowrap; }

.utility-switch { position: relative; display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; padding: 11px; border-radius: 11px; background: #f7f7f4; }
.utility-switch.warning { background: #fffaf0; }
.utility-switch input { margin: 2px 0 0; accent-color: #2d2d2a; }
.utility-switch strong, .utility-switch small { display: block; }
.utility-switch strong { font-size: 9px; }
.utility-switch small { margin-top: 3px; color: #9a8770; font-size: 7px; line-height: 1.45; }

.utility-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 12px; }
.utility-actions button, .utility-file-button { min-height: 38px; border: 1px solid #deded9; border-radius: 11px; background: #f7f7f5; font-size: 9px; }
.utility-actions button.primary { border-color: #292927; background: #292927; color: #fff; }
.utility-file-button { width: 100%; background: #292927; color: #fff; }
.utility-status { min-height: 14px; margin: 9px 0 0; color: #777; font-size: 8px; line-height: 1.5; }
.utility-status[data-state="error"] { color: #a33b35; }
.utility-status[data-state="success"] { color: #39724a; }

.backup-retention { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; color: #666; font-size: 9px; }
.backup-retention select { height: 31px; padding: 0 28px 0 10px; border: 1px solid #deded9; border-radius: 9px; background: #fafaf8; font-size: 9px; }
.mini-toggle input { position: absolute; opacity: 0; }
.mini-toggle i { position: relative; display: block; width: 36px; height: 21px; border-radius: 12px; background: #d8d8d4; transition: .2s; }
.mini-toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15); transition: .2s; }
.mini-toggle input:checked + i { background: #292927; }
.mini-toggle input:checked + i::after { transform: translateX(15px); }
.backup-history { display: grid; gap: 6px; margin: 12px 0; }
.backup-history article { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 10px; border: 1px solid #ecece8; border-radius: 10px; }
.backup-history strong, .backup-history small { display: block; }
.backup-history strong { font-size: 9px; }
.backup-history small { margin-top: 3px; color: #999; font-size: 7px; }
.backup-history div:last-child { display: flex; gap: 5px; }
.backup-history button { min-height: 27px; padding: 0 8px; border: 1px solid #deded9; border-radius: 9px; background: #fafaf8; font-size: 7px; }
.backup-history .backup-delete { color: #a33b35; }
.utility-minor-danger { width: 100%; min-height: 34px; border: 1px solid #ead9d6; border-radius: 10px; background: #fff9f8; color: #9d423b; font-size: 8px; }
.backup-empty { margin: 4px 0; color: #aaa; font-size: 8px; text-align: center; }

.backup-import-review { margin-top: 12px; padding-top: 12px; border-top: 1px solid #ecece8; }
.backup-import-review > header { margin-bottom: 10px; }
.backup-import-review > header strong, .backup-import-review > header small { display: block; }
.backup-import-review > header strong { font-size: 11px; }
.backup-import-review > header small { margin-top: 3px; color: #888; font-size: 8px; line-height: 1.45; }
.import-map-list { display: grid; gap: 6px; }
.import-map-row { display: grid; grid-template-columns: minmax(0,1fr) 115px; gap: 8px; align-items: center; padding: 9px; border: 1px solid #e7e7e2; border-radius: 10px; background: #fafaf8; }
.import-map-row.is-unknown { border-color: #ebd9a9; background: #fffaf0; }
.import-map-row strong, .import-map-row small { display: block; overflow-wrap: anywhere; }
.import-map-row strong { font-size: 9px; }
.import-map-row small { margin-top: 3px; color: #888; font-size: 7px; line-height: 1.4; }
.import-map-row select { width: 100%; height: 31px; border: 1px solid #dcdcd7; border-radius: 8px; background: #fff; font-size: 8px; }
.import-review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 11px; }
.import-review-actions button { min-height: 36px; border: 1px solid #dcdcd7; border-radius: 10px; background: #f7f7f5; font-size: 9px; }
.import-review-actions .primary { border-color: #292927; background: #292927; color: #fff; }

.beauty-scope-tabs { display: flex; gap: 3px; margin: -2px -2px 16px; padding: 2px 2px 9px; overflow-x: auto; border-bottom: 1px solid #e2e2de; scrollbar-width: none; scroll-snap-type: x proximity; }
.beauty-scope-tabs::-webkit-scrollbar { display: none; }
.beauty-scope-tabs button { flex: 0 0 auto; height: 34px; padding: 0 10px; border: 0; border-radius: 0; background: transparent; color: #8b8b85; font-size: 9px; scroll-snap-align: start; }
.beauty-scope-tabs button.active { color: #22221f; box-shadow: inset 0 -2px #22221f; font-weight: 600; }
.beauty-editor-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.beauty-editor-heading > div:first-child { min-width: 0; padding-top: 2px; }
.beauty-editor-tools { display: flex; flex: 0 0 auto; gap: 5px; }
.beauty-editor-tools button { min-height: 34px; padding: 0 9px; border: 1px solid #d9d9d3; border-radius: 8px; background: #fff; color: #555550; font-size: 8px; }
.beauty-editor-tools button:last-child { border-color: #292927; background: #292927; color: #fff; }
#beautyCssInput { box-sizing: border-box; width: 100%; min-height: 245px; margin-top: 12px; padding: 14px; resize: vertical; border: 1px solid #dcdcd7; border-radius: 9px; outline: none; background: #f8f8f5; color: #30302d; font: 11px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; }
#beautyCssInput:focus { border-color: #9d9d98; background: #fff; box-shadow: 0 0 0 3px rgba(40,40,36,.04); }
.beauty-scope-manual { margin-top: 10px; border-top: 1px solid #e3e3df; border-bottom: 1px solid #e3e3df; }
.beauty-scope-manual > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 2px; cursor: pointer; list-style: none; }
.beauty-scope-manual > summary::-webkit-details-marker { display: none; }
.beauty-scope-manual > summary span { color: #2d2d29; font-size: 10px; font-weight: 600; }
.beauty-scope-manual > summary small { max-width: 60%; color: #999993; font-size: 8px; line-height: 1.45; text-align: right; }
.beauty-scope-manual > summary::after { content: "＋"; flex: 0 0 auto; color: #777; font-size: 14px; }
.beauty-scope-manual[open] > summary::after { content: "−"; }
#beautyScopeGuide { padding: 3px 0 16px; color: #60605b; font-size: 9px; line-height: 1.65; }
.beauty-manual-start { display: grid; grid-template-columns: 30px minmax(0,1fr); gap: 10px; padding: 12px; background: #f4f4f0; }
.beauty-manual-start > span { color: #272724; font: 500 18px/1 Georgia, serif; }
.beauty-manual-start strong { color: #2f2f2c; font-size: 10px; }
.beauty-manual-start p { margin: 5px 0 0; }
.beauty-manual-boundary { margin-top: 12px; padding: 11px 12px; border-left: 2px solid #292927; background: #fafaf8; }
.beauty-manual-boundary > span { display: block; margin-bottom: 5px; color: #888; font-size: 7px; letter-spacing: .13em; }
.beauty-manual-boundary p { margin: 7px 0 0; }
#beautyScopeGuide h4 { margin: 16px 1px 8px; color: #30302d; font-size: 10px; }
.beauty-selector-map { display: grid; border-top: 1px solid #e3e3df; }
.beauty-selector-row { display: grid; grid-template-columns: minmax(90px,.78fr) minmax(0,1.22fr); gap: 10px; align-items: start; padding: 10px 1px; border-bottom: 1px solid #e8e8e4; }
.beauty-selector-row strong,.beauty-selector-row small { display: block; }
.beauty-selector-row strong { color: #363633; font-size: 9px; }
.beauty-selector-row small { margin-top: 3px; color: #999993; font-size: 7px; line-height: 1.45; }
.beauty-scope-manual code,.beauty-guide code { display: inline-block; max-width: 100%; padding: 3px 5px; border-radius: 3px; background: #efefeb; color: #343431; font: 8px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; word-break: break-word; }
.beauty-selector-row > code { justify-self: stretch; background: #f6f6f3; }
.beauty-function-guard { padding: 1px 11px 10px; border: 1px solid #e3e3de; background: #fff; }
.beauty-function-guard ul { margin: 0; padding-left: 17px; }
.beauty-function-guard li + li { margin-top: 7px; }

.beauty-guide { margin: 2px 0 16px; border: 1px solid #deded9; border-radius: 12px; background: #fff; }
.beauty-guide > summary { padding: 15px; cursor: pointer; font-size: 10px; font-weight: 600; }
.beauty-guide > div { padding: 0 15px 16px; color: #666; font-size: 9px; line-height: 1.65; }
.beauty-guide h4 { margin: 17px 0 7px; color: #333; font-size: 10px; }
.beauty-guide p { margin: 7px 0; }
.beauty-guide-lead { padding: 12px; border-left: 2px solid #292927; background: #f5f5f2; }
.beauty-guide-lead strong { color: #2d2d2a; font-size: 11px; }
.beauty-guide-lead ol { margin: 8px 0 0; padding-left: 18px; }
.beauty-guide-lead li + li { margin-top: 5px; }
.beauty-guide-index { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
.beauty-guide-index button { min-width: 0; padding: 10px; border: 1px solid #e4e4e0; border-radius: 8px; background: #fafaf8; text-align: left; }
.beauty-guide-index strong,.beauty-guide-index small,.beauty-guide-index code { display: block; }
.beauty-guide-index strong { color: #333; font-size: 9px; }
.beauty-guide-index small { min-height: 2.8em; margin: 3px 0 7px; color: #999; font-size: 7px; line-height: 1.4; }
.beauty-guide-index code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.beauty-global-warning { margin-top: 14px!important; padding: 10px; border: 1px solid #eadfca; background: #fffaf0; color: #79664c; }

@media (max-width: 350px) {
  .backup-app-grid { grid-template-columns: 1fr; }
  .import-map-row { grid-template-columns: 1fr; }
  .beauty-editor-heading { display: grid; }
  .beauty-editor-tools { display: grid; grid-template-columns: 1fr 1fr; }
  .beauty-selector-row { grid-template-columns: 1fr; gap: 5px; }
  .beauty-guide-index { grid-template-columns: 1fr; }
}

@media (max-height: 700px) {
  .utility-app-head strong { font-size: 19px; }
  .utility-card { padding: 12px; }
}
