{
  "schemaVersion": "1.0",
  "id": "settings",
  "title": "Cài đặt",
  "purpose": "Account/app/privacy settings grouped; no developer controls inside product.",
  "roles": [
    "adult"
  ],
  "group": "settings-privacy",
  "variantOf": null,
  "layout": {
    "canvas": {
      "width": 390,
      "height": 844
    },
    "responsive": {
      "minimumWidth": 360,
      "maximumWidth": 430,
      "scroll": "vertical",
      "safeAreaBottom": true,
      "fontScale": "native dynamic type; reflow without clipping",
      "keyboard": "composer sticky within resized viewport; dialog scrolls; no fixed keyboard overlay"
    },
    "regions": [
      {
        "id": "header",
        "order": 0,
        "type": "safe-area/header",
        "height": "intrinsic"
      },
      {
        "id": "content",
        "order": 1,
        "type": "purpose-specific preferences",
        "componentIds": [
          "screen-header",
          "settings-0",
          "settings-1",
          "settings-2",
          "settings-3",
          "settings-4",
          "settings-5",
          "screen-actions"
        ]
      },
      {
        "id": "actions",
        "order": 2,
        "type": "one primary + secondary controls"
      },
      {
        "id": "navigation",
        "order": 3,
        "type": "none"
      }
    ]
  },
  "components": [
    {
      "id": "screen-header",
      "type": "Header",
      "props": {
        "homeLabel": "Nhà Lá",
        "scopeGate": "A",
        "backTarget": "today",
        "settingsTarget": "settings"
      },
      "tokens": {
        "foreground": "{semantic.light.fg}",
        "darkForeground": "{semantic.dark.fg}"
      },
      "accessibility": {
        "label": "Thanh đầu màn hình",
        "readingOrder": 0,
        "focusOrder": "back then settings"
      }
    },
    {
      "id": "settings-0",
      "type": "SectionHeading",
      "props": {
        "text": "Tài khoản và nhà"
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Cài đặt · SectionHeading",
        "readingOrder": 1,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "settings-1",
      "type": "SettingsGroup",
      "props": {
        "items": [
          {
            "label": "Hồ sơ của tôi",
            "description": "Tên hiển thị và email người lớn",
            "target": "profile"
          },
          {
            "label": "Nhà Lá",
            "description": "Tên, múi giờ và quyền chủ nhà",
            "target": "household-settings"
          },
          {
            "label": "Gói của nhà",
            "description": "Quyền Free / Pro",
            "target": "subscription-status"
          }
        ]
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Cài đặt · SettingsGroup",
        "readingOrder": 2,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "settings-2",
      "type": "SectionHeading",
      "props": {
        "text": "Ứng dụng"
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Cài đặt · SectionHeading",
        "readingOrder": 3,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "settings-3",
      "type": "SettingsGroup",
      "props": {
        "items": [
          {
            "label": "Thông báo",
            "description": "Nhắc việc, duyệt bài và giờ yên lặng",
            "target": "notification-settings"
          },
          {
            "label": "Giao diện và ngôn ngữ",
            "description": "Sáng, tối, tiếng Việt",
            "target": "appearance-language"
          }
        ]
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Cài đặt · SettingsGroup",
        "readingOrder": 4,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "settings-4",
      "type": "SectionHeading",
      "props": {
        "text": "Dữ liệu và hỗ trợ"
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Cài đặt · SectionHeading",
        "readingOrder": 5,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "settings-5",
      "type": "SettingsGroup",
      "props": {
        "items": [
          {
            "label": "Quyền riêng tư",
            "description": "Xuất dữ liệu, rời nhà và xóa tài khoản",
            "target": "privacy"
          },
          {
            "label": "Trợ giúp",
            "description": "Cách dùng và thông tin ứng dụng",
            "target": "help-about"
          }
        ]
      },
      "tokens": {
        "background": "{semantic.light.surface}",
        "foreground": "{semantic.light.fg}",
        "darkBackground": "{semantic.dark.surface}",
        "darkForeground": "{semantic.dark.fg}",
        "bodySize": "{primitive.type.body}",
        "touchTarget": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Cài đặt · SettingsGroup",
        "readingOrder": 6,
        "colorOnly": false,
        "fontScaling": true,
        "minimumTouchTarget": 48,
        "instructions": "Đọc theo thứ tự; công bố nhãn trạng thái và lỗi, không chỉ màu."
      }
    },
    {
      "id": "screen-actions",
      "type": "ActionGroup",
      "props": {
        "actions": [
          {
            "id": "logout",
            "label": "Đăng xuất bản mẫu",
            "kind": "mutate",
            "target": "entry-mode",
            "confirmationRequired": true
          },
          {
            "id": "link-today",
            "label": "Hôm nay",
            "kind": "navigate",
            "target": "today",
            "confirmationRequired": false
          },
          {
            "id": "link-settings",
            "label": "Cài đặt",
            "kind": "navigate",
            "target": "settings",
            "confirmationRequired": false
          },
          {
            "id": "link-profile",
            "label": "Hồ sơ của tôi",
            "kind": "navigate",
            "target": "profile",
            "confirmationRequired": false
          },
          {
            "id": "link-household-settings",
            "label": "Nhà Lá",
            "kind": "navigate",
            "target": "household-settings",
            "confirmationRequired": false
          },
          {
            "id": "link-subscription-status",
            "label": "Gói của nhà",
            "kind": "navigate",
            "target": "subscription-status",
            "confirmationRequired": false
          },
          {
            "id": "link-notification-settings",
            "label": "Thông báo của bạn",
            "kind": "navigate",
            "target": "notification-settings",
            "confirmationRequired": false
          },
          {
            "id": "link-appearance-language",
            "label": "Giao diện và ngôn ngữ",
            "kind": "navigate",
            "target": "appearance-language",
            "confirmationRequired": false
          },
          {
            "id": "link-privacy",
            "label": "Dữ liệu của bạn",
            "kind": "navigate",
            "target": "privacy",
            "confirmationRequired": false
          },
          {
            "id": "link-help-about",
            "label": "Chia Việc, cùng bạn",
            "kind": "navigate",
            "target": "help-about",
            "confirmationRequired": false
          }
        ],
        "primaryCount": 0
      },
      "tokens": {
        "lightBackground": "{component.light.button.background}",
        "lightForeground": "{component.light.button.foreground}",
        "darkBackground": "{component.dark.button.background}",
        "darkForeground": "{component.dark.button.foreground}",
        "height": "{primitive.space.48}"
      },
      "accessibility": {
        "label": "Hành động của màn hình",
        "keyboard": true,
        "focusVisible": true,
        "disabledOnlyLowContrast": true
      }
    }
  ],
  "fields": [],
  "states": [
    {
      "id": "adult",
      "when": "Adult session resolved",
      "visibleUI": "Grouped rows by capability",
      "availableActions": [
        "logout",
        "link-today",
        "link-settings",
        "link-profile",
        "link-household-settings",
        "link-subscription-status",
        "link-notification-settings",
        "link-appearance-language",
        "link-privacy",
        "link-help-about"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "non-owner",
      "when": "No O capability",
      "visibleUI": "Home owner control read-only",
      "availableActions": [
        "link-today",
        "link-settings",
        "link-profile",
        "link-household-settings",
        "link-subscription-status",
        "link-notification-settings",
        "link-appearance-language",
        "link-privacy",
        "link-help-about"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    },
    {
      "id": "offline",
      "when": "Cached settings",
      "visibleUI": "Online-only account actions unavailable",
      "availableActions": [
        "link-today",
        "link-settings",
        "link-profile",
        "link-household-settings",
        "link-subscription-status",
        "link-notification-settings",
        "link-appearance-language",
        "link-privacy",
        "link-help-about"
      ],
      "mutationPolicy": "Actor, exact capability and current versions must still pass; this state never grants rights."
    }
  ],
  "actions": [
    {
      "id": "logout",
      "label": "Đăng xuất bản mẫu",
      "kind": "mutate",
      "targetScreenId": "entry-mode",
      "permission": "U own session",
      "confirmationRequired": true,
      "contractRef": "POST /v1/session/logout",
      "localBehavior": "Only validated draft/local domain where supported; remote adapters never report success.",
      "idempotency": "Stable actor/household/command key and canonical body; changed payload is a new confirmed intent."
    },
    {
      "id": "link-today",
      "label": "Hôm nay",
      "kind": "navigate",
      "targetScreenId": "today",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-settings",
      "label": "Cài đặt",
      "kind": "navigate",
      "targetScreenId": "settings",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-profile",
      "label": "Hồ sơ của tôi",
      "kind": "navigate",
      "targetScreenId": "profile",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-household-settings",
      "label": "Nhà Lá",
      "kind": "navigate",
      "targetScreenId": "household-settings",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-subscription-status",
      "label": "Gói của nhà",
      "kind": "navigate",
      "targetScreenId": "subscription-status",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-notification-settings",
      "label": "Thông báo của bạn",
      "kind": "navigate",
      "targetScreenId": "notification-settings",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-appearance-language",
      "label": "Giao diện và ngôn ngữ",
      "kind": "navigate",
      "targetScreenId": "appearance-language",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-privacy",
      "label": "Dữ liệu của bạn",
      "kind": "navigate",
      "targetScreenId": "privacy",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    },
    {
      "id": "link-help-about",
      "label": "Chia Việc, cùng bạn",
      "kind": "navigate",
      "targetScreenId": "help-about",
      "permission": "A",
      "confirmationRequired": false,
      "contractRef": "local navigation"
    }
  ],
  "dataBindings": [
    {
      "source": "GET /v1/me",
      "shape": {
        "version": "integer",
        "weekday_budgets": "{weekday:1..7,effort_budget:integer}[] (SchedulePreferencesDto, schedule screens only)",
        "notifications": "NotificationPreferencesDto {locale:vi|en, enabled, quiet_start_local HH:mm|null, quiet_end_local HH:mm|null, version}",
        "theme": "device-local light|dark|system; not an API field"
      },
      "sample": {
        "version": 1,
        "weekday_budgets": [
          {
            "weekday": 1,
            "effort_budget": 4
          },
          {
            "weekday": 2,
            "effort_budget": 4
          },
          {
            "weekday": 3,
            "effort_budget": 4
          },
          {
            "weekday": 4,
            "effort_budget": 4
          },
          {
            "weekday": 5,
            "effort_budget": 4
          },
          {
            "weekday": 6,
            "effort_budget": 6
          },
          {
            "weekday": 7,
            "effort_budget": 6
          }
        ],
        "notifications": {
          "locale": "vi",
          "enabled": true,
          "quiet_start_local": "21:00",
          "quiet_end_local": "07:00",
          "version": 1
        },
        "theme": "light"
      },
      "sampleOnly": true,
      "actorConstraint": "exact actor allowlist",
      "envelope": "API refs use CommandEnvelope; local review context is not an API property."
    }
  ],
  "copy": {
    "heading": "Cài đặt",
    "primary": null,
    "empty": null,
    "notices": [],
    "locale": "vi",
    "demoLabel": "Bản thiết kế · dữ liệu mẫu · không kết nối dịch vụ"
  },
  "implementation": {
    "nativeRoute": "/design/settings",
    "nativeRouteStatus": "proposed mapping, verify against implementing native navigator",
    "apiRefs": [
      "GET /v1/me"
    ],
    "newContractRefs": [],
    "notes": [
      "Tất cả ví dụ là dữ liệu thiết kế, không bằng chứng native/API/store đã chạy.",
      "Native route dưới đây là đề xuất mapping cho agent, không tuyên bố route source đã tồn tại.",
      "Mọi mutation dùng envelope {data,version,household_revision,replayed}, stable Idempotency-Key và expected_version khi sửa."
    ],
    "integrationStatus": "design complete; local static/draft interactions; native/API adapters pending",
    "sourceAuthority": [
      "docs/product-brief.md",
      "plans/261013-1409-sweepy-vietnam-mobile/mobile-flows.md",
      "plans/261013-1409-sweepy-vietnam-mobile/api-contracts.md",
      "packages/domain/src/contracts/phase2.ts",
      "packages/domain/src/index.ts",
      "packages/domain/src/contracts/phase3.ts",
      "packages/domain/src/contracts/billing.ts",
      "apps/mobile/src/lib/api.ts"
    ],
    "capability": "A",
    "errors": {
      "401": "Stop queue; adult login or child re-pair without parent account.",
      "403": "Do not retry lost capability. FEATURE_REQUIRED never grants Pro.",
      "409": "Fetch canonical scoped state; review/reconfirm new intent, do not rewrite old replay payload.",
      "422": "Field error with retained draft.",
      "429": "Respect Retry-After.",
      "503": "Backoff only retryable commands with original key."
    }
  }
}
