{
  "id": "pilot_radio_reference",
  "type": "module",
  "version": "1.0",
  "context": {
    "layout": "phone",
    "title": "Pilot Radio Reference",
    "icon": "✈️",
    "results": "${entries[(kind == ${mode} || ${mode} == 'Favorites') && (${mode} != 'Favorites' || contains(${favorites}, id)) && (${mode} != 'Phrases' || ${category} == 'All categories' || category == ${category}) && contains(lower(title + ' ' + subtitle + ' ' + category + ' ' + meaning), lower(trim(${query})))]}"
  },
  "state": {
    "mode": "Alphabet",
    "query": "",
    "category": "All categories",
    "focused": "",
    "entries": [
      {
        "id": "A",
        "kind": "Alphabet",
        "title": "Alfa",
        "subtitle": "AL fah",
        "category": "ICAO alphabet",
        "meaning": "Letter A",
        "letter": "A"
      },
      {
        "id": "B",
        "kind": "Alphabet",
        "title": "Bravo",
        "subtitle": "BRAH voh",
        "category": "ICAO alphabet",
        "meaning": "Letter B",
        "letter": "B"
      },
      {
        "id": "C",
        "kind": "Alphabet",
        "title": "Charlie",
        "subtitle": "CHAR lee / SHAR lee",
        "category": "ICAO alphabet",
        "meaning": "Letter C",
        "letter": "C"
      },
      {
        "id": "D",
        "kind": "Alphabet",
        "title": "Delta",
        "subtitle": "DELL tah",
        "category": "ICAO alphabet",
        "meaning": "Letter D",
        "letter": "D"
      },
      {
        "id": "E",
        "kind": "Alphabet",
        "title": "Echo",
        "subtitle": "ECK oh",
        "category": "ICAO alphabet",
        "meaning": "Letter E",
        "letter": "E"
      },
      {
        "id": "F",
        "kind": "Alphabet",
        "title": "Foxtrot",
        "subtitle": "FOKS trot",
        "category": "ICAO alphabet",
        "meaning": "Letter F",
        "letter": "F"
      },
      {
        "id": "G",
        "kind": "Alphabet",
        "title": "Golf",
        "subtitle": "GOLF",
        "category": "ICAO alphabet",
        "meaning": "Letter G",
        "letter": "G"
      },
      {
        "id": "H",
        "kind": "Alphabet",
        "title": "Hotel",
        "subtitle": "hoh TELL",
        "category": "ICAO alphabet",
        "meaning": "Letter H",
        "letter": "H"
      },
      {
        "id": "I",
        "kind": "Alphabet",
        "title": "India",
        "subtitle": "IN dee ah",
        "category": "ICAO alphabet",
        "meaning": "Letter I",
        "letter": "I"
      },
      {
        "id": "J",
        "kind": "Alphabet",
        "title": "Juliett",
        "subtitle": "JEW lee ETT",
        "category": "ICAO alphabet",
        "meaning": "Letter J",
        "letter": "J"
      },
      {
        "id": "K",
        "kind": "Alphabet",
        "title": "Kilo",
        "subtitle": "KEY loh",
        "category": "ICAO alphabet",
        "meaning": "Letter K",
        "letter": "K"
      },
      {
        "id": "L",
        "kind": "Alphabet",
        "title": "Lima",
        "subtitle": "LEE mah",
        "category": "ICAO alphabet",
        "meaning": "Letter L",
        "letter": "L"
      },
      {
        "id": "M",
        "kind": "Alphabet",
        "title": "Mike",
        "subtitle": "MIKE",
        "category": "ICAO alphabet",
        "meaning": "Letter M",
        "letter": "M"
      },
      {
        "id": "N",
        "kind": "Alphabet",
        "title": "November",
        "subtitle": "no VEM ber",
        "category": "ICAO alphabet",
        "meaning": "Letter N",
        "letter": "N"
      },
      {
        "id": "O",
        "kind": "Alphabet",
        "title": "Oscar",
        "subtitle": "OSS cah",
        "category": "ICAO alphabet",
        "meaning": "Letter O",
        "letter": "O"
      },
      {
        "id": "P",
        "kind": "Alphabet",
        "title": "Papa",
        "subtitle": "pah PAH",
        "category": "ICAO alphabet",
        "meaning": "Letter P",
        "letter": "P"
      },
      {
        "id": "Q",
        "kind": "Alphabet",
        "title": "Quebec",
        "subtitle": "keh BECK",
        "category": "ICAO alphabet",
        "meaning": "Letter Q",
        "letter": "Q"
      },
      {
        "id": "R",
        "kind": "Alphabet",
        "title": "Romeo",
        "subtitle": "ROW me oh",
        "category": "ICAO alphabet",
        "meaning": "Letter R",
        "letter": "R"
      },
      {
        "id": "S",
        "kind": "Alphabet",
        "title": "Sierra",
        "subtitle": "see AIR rah",
        "category": "ICAO alphabet",
        "meaning": "Letter S",
        "letter": "S"
      },
      {
        "id": "T",
        "kind": "Alphabet",
        "title": "Tango",
        "subtitle": "TANG go",
        "category": "ICAO alphabet",
        "meaning": "Letter T",
        "letter": "T"
      },
      {
        "id": "U",
        "kind": "Alphabet",
        "title": "Uniform",
        "subtitle": "YOU nee form / OO nee form",
        "category": "ICAO alphabet",
        "meaning": "Letter U",
        "letter": "U"
      },
      {
        "id": "V",
        "kind": "Alphabet",
        "title": "Victor",
        "subtitle": "VIK tah",
        "category": "ICAO alphabet",
        "meaning": "Letter V",
        "letter": "V"
      },
      {
        "id": "W",
        "kind": "Alphabet",
        "title": "Whiskey",
        "subtitle": "WISS key",
        "category": "ICAO alphabet",
        "meaning": "Letter W",
        "letter": "W"
      },
      {
        "id": "X",
        "kind": "Alphabet",
        "title": "X-ray",
        "subtitle": "ECKS RAY",
        "category": "ICAO alphabet",
        "meaning": "Letter X",
        "letter": "X"
      },
      {
        "id": "Y",
        "kind": "Alphabet",
        "title": "Yankee",
        "subtitle": "YANG key",
        "category": "ICAO alphabet",
        "meaning": "Letter Y",
        "letter": "Y"
      },
      {
        "id": "Z",
        "kind": "Alphabet",
        "title": "Zulu",
        "subtitle": "ZOO loo",
        "category": "ICAO alphabet",
        "meaning": "Letter Z",
        "letter": "Z"
      },
      {
        "id": "roger",
        "kind": "Phrases",
        "title": "ROGER",
        "subtitle": "Message received",
        "category": "Radio basics",
        "meaning": "I have received all of your last transmission.",
        "example": "ROGER, [call sign].",
        "note": "Not an affirmative answer and not a substitute for a required readback. It does not mean you will comply."
      },
      {
        "id": "wilco",
        "kind": "Phrases",
        "title": "WILCO",
        "subtitle": "Understood; will comply",
        "category": "Radio basics",
        "meaning": "I understand your message and will comply with it.",
        "example": "WILCO, [call sign].",
        "note": "Do not use in place of a required readback of a clearance or instruction."
      },
      {
        "id": "affirm",
        "kind": "Phrases",
        "title": "AFFIRM",
        "subtitle": "Yes",
        "category": "Radio basics",
        "meaning": "Yes.",
        "example": "AFFIRM, [call sign].",
        "note": "Use the standard word AFFIRM. A clearance requiring readback still needs the applicable readback."
      },
      {
        "id": "negative",
        "kind": "Phrases",
        "title": "NEGATIVE",
        "subtitle": "No, or not correct",
        "category": "Radio basics",
        "meaning": "No; permission not granted; or that is not correct.",
        "example": "NEGATIVE, [call sign].",
        "note": "Add a concise clarification if a simple negative answer could be ambiguous."
      },
      {
        "id": "standby",
        "kind": "Phrases",
        "title": "STANDBY",
        "subtitle": "Wait; I will call you",
        "category": "Radio basics",
        "meaning": "Wait and I will call you.",
        "example": "[Call sign], STANDBY.",
        "note": "Normally used by the station asking you to wait. This is neither approval nor denial of a request."
      },
      {
        "id": "say_again",
        "kind": "Phrases",
        "title": "SAY AGAIN",
        "subtitle": "Request a repeat",
        "category": "Clarification",
        "meaning": "Repeat all, or the specified part, of your last transmission.",
        "example": "[Station], [call sign], SAY AGAIN.",
        "note": "Specify the missing part when useful, such as SAY AGAIN ALL AFTER [word]. Do not guess an unclear instruction."
      },
      {
        "id": "speak_slower",
        "kind": "Phrases",
        "title": "SPEAK SLOWER",
        "subtitle": "Reduce speaking speed",
        "category": "Clarification",
        "meaning": "Reduce your rate of speech.",
        "example": "[Station], [call sign], SPEAK SLOWER.",
        "note": "Use when the transmission is too fast to understand accurately."
      },
      {
        "id": "confirm",
        "kind": "Phrases",
        "title": "CONFIRM",
        "subtitle": "Verify a specific detail",
        "category": "Clarification",
        "meaning": "I request verification of a clearance, instruction, action or information.",
        "example": "[Station], [call sign], CONFIRM [detail].",
        "note": "Identify exactly what needs checking. Do not act on an uncertain clearance."
      },
      {
        "id": "correction",
        "kind": "Phrases",
        "title": "CORRECTION",
        "subtitle": "Correct your own transmission",
        "category": "Clarification",
        "meaning": "An error has been made in this transmission. The correct version follows.",
        "example": "[Incorrect information], CORRECTION, [correct information].",
        "note": "Clearly identify the corrected information so the receiver knows which value to use."
      },
      {
        "id": "readback",
        "kind": "Phrases",
        "title": "READ BACK",
        "subtitle": "Repeat a message exactly",
        "category": "Clarification",
        "meaning": "Repeat all, or the specified part, of this message back to me exactly as received.",
        "example": "[Call sign], READ BACK [specified information].",
        "note": "A pilot must read back safety-related clearance elements as required by applicable procedures, even without this explicit request."
      },
      {
        "id": "request_start",
        "kind": "Phrases",
        "title": "REQUEST START-UP",
        "subtitle": "Ask for start-up approval",
        "category": "Ground",
        "meaning": "Request permission to start engines where start-up approval is required.",
        "example": "[Station], [call sign], [position], REQUEST START-UP.",
        "note": "Include ATIS information or other details when required locally. This request does not authorize start-up or movement."
      },
      {
        "id": "request_taxi",
        "kind": "Phrases",
        "title": "REQUEST TAXI",
        "subtitle": "Ask for taxi instructions",
        "category": "Ground",
        "meaning": "Request taxi instructions from the appropriate ground station.",
        "example": "[Station], [call sign], [position], REQUEST TAXI.",
        "note": "Supply destination, flight details and ATIS information as required. A taxi clearance is not a take-off clearance."
      },
      {
        "id": "hold_short",
        "kind": "Phrases",
        "title": "HOLD SHORT OF",
        "subtitle": "Stop before a specified point",
        "category": "Ground",
        "meaning": "An instruction not to proceed beyond the specified holding point or boundary.",
        "example": "HOLD SHORT OF RUNWAY [designator], [call sign].",
        "note": "The example is a readback, not a clearance. Read back runway holding instructions with the runway designator and call sign."
      },
      {
        "id": "ready_departure",
        "kind": "Phrases",
        "title": "READY FOR DEPARTURE",
        "subtitle": "Report readiness",
        "category": "Departure & arrival",
        "meaning": "Advise that the aircraft is ready for departure.",
        "example": "[Tower], [call sign], READY FOR DEPARTURE.",
        "note": "Use DEPARTURE for readiness reports. TAKE-OFF is reserved for take-off clearances and their cancellation. Readiness is not permission to enter a runway."
      },
      {
        "id": "line_up",
        "kind": "Phrases",
        "title": "LINE UP AND WAIT",
        "subtitle": "Enter and wait on the runway",
        "category": "Departure & arrival",
        "meaning": "ATC instruction to enter the specified runway and wait in position.",
        "example": "LINE UP AND WAIT RUNWAY [designator], [call sign].",
        "note": "The example is a readback. This is NOT a take-off clearance. Comply only with an actual clearance and applicable runway-safety procedures."
      },
      {
        "id": "going_around",
        "kind": "Phrases",
        "title": "GOING AROUND",
        "subtitle": "Report a go-around",
        "category": "Departure & arrival",
        "meaning": "Pilot report that a go-around is being carried out.",
        "example": "[Tower], [call sign], GOING AROUND.",
        "note": "Aircraft control and the applicable go-around procedure come first. Follow subsequent ATC instructions as appropriate."
      },
      {
        "id": "runway_vacated",
        "kind": "Phrases",
        "title": "RUNWAY VACATED",
        "subtitle": "Report clear of the runway",
        "category": "Departure & arrival",
        "meaning": "Report that the entire aircraft is clear of the runway in accordance with the applicable local definition.",
        "example": "[Tower], [call sign], RUNWAY VACATED.",
        "note": "Do not report vacated while any part of the aircraft remains within the runway holding-position boundary."
      },
      {
        "id": "request_climb",
        "kind": "Phrases",
        "title": "REQUEST CLIMB",
        "subtitle": "Ask for a higher level",
        "category": "En route",
        "meaning": "Request a climb to a specified altitude or flight level.",
        "example": "[Station], [call sign], REQUEST CLIMB TO [altitude or flight level].",
        "note": "Use the correct altitude or flight-level convention and units for the airspace. A request is not a clearance."
      },
      {
        "id": "request_descent",
        "kind": "Phrases",
        "title": "REQUEST DESCENT",
        "subtitle": "Ask for a lower level",
        "category": "En route",
        "meaning": "Request a descent to a specified altitude or flight level.",
        "example": "[Station], [call sign], REQUEST DESCENT TO [altitude or flight level].",
        "note": "Do not change level on the strength of a request alone. Apply the actual clearance and applicable procedures."
      },
      {
        "id": "unable",
        "kind": "Phrases",
        "title": "UNABLE",
        "subtitle": "Cannot comply",
        "category": "En route",
        "meaning": "I cannot comply with your request, instruction or clearance.",
        "example": "[Station], [call sign], UNABLE [instruction], [brief reason].",
        "note": "State the reason when practicable and request an alternative as needed. Do not acknowledge compliance if you cannot comply."
      },
      {
        "id": "traffic_sight",
        "kind": "Phrases",
        "title": "TRAFFIC IN SIGHT",
        "subtitle": "Report visual acquisition",
        "category": "En route",
        "meaning": "Report that the traffic referred to by ATC has been seen.",
        "example": "[Call sign], TRAFFIC IN SIGHT.",
        "note": "Use only for traffic actually identified visually. Seeing a target on an electronic display alone is not visual acquisition."
      },
      {
        "id": "negative_contact",
        "kind": "Phrases",
        "title": "NEGATIVE CONTACT",
        "subtitle": "Traffic not seen",
        "category": "En route",
        "meaning": "Report that the traffic referred to by ATC has not been seen.",
        "example": "[Call sign], NEGATIVE CONTACT.",
        "note": "This is a traffic-sighting report, not a general radio-failure message."
      },
      {
        "id": "mayday",
        "kind": "Phrases",
        "title": "MAYDAY",
        "subtitle": "Distress • immediate assistance",
        "category": "Urgency & distress",
        "meaning": "Distress signal: grave and imminent danger requiring immediate assistance.",
        "example": "MAYDAY, MAYDAY, MAYDAY, [station], [call sign], [nature of distress], [intentions], [position, level and heading].",
        "note": "Prioritize flying the aircraft. Transmit useful details as circumstances permit and follow trained emergency procedures. This is a memory aid, not a complete emergency checklist."
      },
      {
        "id": "pan_pan",
        "kind": "Phrases",
        "title": "PAN PAN",
        "subtitle": "Urgency • safety concern",
        "category": "Urgency & distress",
        "meaning": "Urgency signal: a condition concerning the safety of an aircraft or person, but not requiring immediate assistance.",
        "example": "PAN PAN, PAN PAN, PAN PAN, [station], [call sign], [nature of urgency], [intentions], [position, level and heading].",
        "note": "Use MAYDAY when the situation meets the distress criteria. Transmit useful details as circumstances permit; this is not a complete emergency checklist."
      },
      {
        "id": "minimum_fuel",
        "kind": "Phrases",
        "title": "MINIMUM FUEL",
        "subtitle": "No additional delay acceptable",
        "category": "Urgency & distress",
        "meaning": "Having committed to land at a specific aerodrome, any change to the existing clearance may result in landing with less than planned final reserve fuel.",
        "example": "[Station], [call sign], MINIMUM FUEL.",
        "note": "This is not an emergency declaration and does not imply priority. Declare MAYDAY MAYDAY MAYDAY FUEL when predicted fuel on landing at the nearest aerodrome where a safe landing can be made is less than planned final reserve fuel."
      }
    ],
    "favorites": [],
    "previousFavorites": [],
    "canUndo": false,
    "loading": true,
    "saveError": false,
    "status": ""
  },
  "dependencies": [
    {
      "repository": {
        "local": {
          "id": "pilot_radio_reference_v1",
          "config": {}
        }
      }
    },
    {
      "service": {
        "audio": {
          "id": "radio_haptics"
        }
      }
    },
    {
      "action": {
        "repo": {
          "id": "persist_favorites",
          "input": {
            "repositoryId": "pilot_radio_reference_v1",
            "operation": "create",
            "params": {
              "collection": "preferences",
              "documentId": "favorites",
              "rewrite": true,
              "body": {
                "favorites": "${favorites}"
              }
            }
          },
          "output": {
            "success": [
              {
                "state": {
                  "id": "persist_ok",
                  "input": {
                    "saveError": false,
                    "status": "Favorites updated on this device."
                  }
                }
              },
              {
                "service": {
                  "id": "persist_haptic",
                  "input": {
                    "serviceId": "radio_haptics",
                    "params": {
                      "haptic": "success"
                    }
                  }
                }
              }
            ],
            "failure": [
              {
                "state": {
                  "id": "persist_failed",
                  "input": {
                    "saveError": true,
                    "status": "Could not save favorites. Retry before leaving."
                  }
                }
              }
            ]
          }
        }
      }
    },
    {
      "action": {
        "state": {
          "id": "toggle_favorite",
          "input": {
            "previousFavorites": "${favorites}",
            "favorites": "{{ contains(${favorites}, @{item.id}) ? ${favorites} - @{item.id} : ${favorites} + @{item.id} }}",
            "canUndo": true,
            "focused": "",
            "status": "Saving favorites…"
          },
          "output": {
            "success": [
              {
                "template": {
                  "id": "toggle_persist",
                  "input": "persist_favorites"
                }
              }
            ]
          }
        }
      }
    }
  ],
  "events": {
    "onAppear": [
      {
        "repo": {
          "id": "load_favorites",
          "input": {
            "repositoryId": "pilot_radio_reference_v1",
            "operation": "read",
            "params": {
              "collection": "preferences",
              "documentId": "favorites"
            }
          },
          "output": {
            "success": [
              {
                "state": {
                  "id": "hydrate_favorites",
                  "input": {
                    "favorites": "{{ @{load_favorites.favorites} ?? [] }}",
                    "loading": false
                  }
                }
              }
            ],
            "failure": [
              {
                "state": {
                  "id": "first_launch",
                  "input": {
                    "loading": false
                  }
                }
              }
            ]
          }
        }
      }
    ]
  },
  "children": [
    {
      "id": "radio_nav",
      "type": "navigation",
      "children": [
        {
          "id": "radio_scroll",
          "type": "scroll",
          "style": {
            "layout": {
              "maxWidth": "infinity",
              "maxHeight": "infinity"
            },
            "scroll": {
              "dismissesKeyboard": "interactively"
            }
          },
          "children": [
            {
              "id": "radio_stack",
              "type": "vstack",
              "context": {
                "_spacing": 20,
                "_alignment": "leading"
              },
              "style": {
                "layout": {
                  "padding": 20,
                  "maxWidth": "infinity"
                }
              },
              "children": [
                {
                  "id": "intro_card",
                  "type": "vstack",
                  "context": {
                    "_spacing": 8,
                    "_alignment": "leading"
                  },
                  "style": {
                    "layout": {
                      "maxWidth": "infinity",
                      "padding": 18
                    },
                    "common": {
                      "background": {
                        "gradient": {
                          "linear": {
                            "colors": [
                              "#183B53",
                              "#102638"
                            ],
                            "startPoint": "topLeading",
                            "endPoint": "bottomTrailing"
                          }
                        }
                      },
                      "foreground": {
                        "color": "white"
                      },
                      "cornerRadius": 20
                    },
                    "shadow": {
                      "color": "#000000",
                      "radius": 8,
                      "x": 0,
                      "y": 4
                    }
                  },
                  "children": [
                    {
                      "id": "intro_eyebrow",
                      "type": "label",
                      "context": {
                        "_title": "OFFLINE • RADIO REFERENCE",
                        "_image": "sf://antenna.radiowaves.left.and.right"
                      },
                      "style": {
                        "common": {
                          "font": {
                            "kind": "caption",
                            "weight": "semibold"
                          },
                          "foreground": {
                            "color": "white"
                          }
                        }
                      }
                    },
                    {
                      "id": "intro_heading",
                      "type": "text",
                      "context": {
                        "_text": "{{ ${mode} == 'Alphabet' ? 'Clear letters. Clear calls.' : (${mode} == 'Phrases' ? 'The right words, at a glance.' : 'Your quick-access reference.') }}"
                      },
                      "style": {
                        "common": {
                          "font": {
                            "kind": "title2",
                            "weight": "bold"
                          },
                          "foreground": {
                            "color": "white"
                          }
                        }
                      }
                    },
                    {
                      "id": "intro_safety",
                      "type": "text",
                      "context": {
                        "_text": "Memory aid only. Current AIP, ATC instructions and operator procedures take precedence."
                      },
                      "style": {
                        "common": {
                          "font": "caption",
                          "foreground": {
                            "color": "white"
                          }
                        }
                      }
                    }
                  ]
                },
                {
                  "id": "controls_card",
                  "type": "vstack",
                  "context": {
                    "_spacing": 12,
                    "_alignment": "leading"
                  },
                  "style": {
                    "layout": {
                      "maxWidth": "infinity",
                      "padding": 18
                    },
                    "common": {
                      "background": {
                        "color": "surface"
                      },
                      "foreground": {
                        "color": "onSurface"
                      },
                      "cornerRadius": 18
                    },
                    "shadow": {
                      "color": "#000000",
                      "radius": 3,
                      "x": 0,
                      "y": 2
                    }
                  },
                  "children": [
                    {
                      "id": "collection_picker",
                      "type": "picker",
                      "context": {
                        "_label": "Reference collection",
                        "_selection": "${mode}",
                        "_options": [
                          "Alphabet",
                          "Phrases",
                          "Favorites"
                        ]
                      },
                      "style": {
                        "picker": "segmented",
                        "layout": {
                          "minHeight": 44
                        }
                      }
                    },
                    {
                      "id": "reference_search",
                      "type": "textfield",
                      "context": {
                        "_label": "Search letters, words or meanings",
                        "_text": "${query}",
                        "_focused": "${focused}",
                        "_debounce": 0
                      },
                      "style": {
                        "layout": {
                          "minHeight": 44
                        },
                        "textField": {
                          "standard": "roundedBorder",
                          "autocapitalization": "none",
                          "autocorrectionDisabled": true
                        },
                        "common": {
                          "foreground": {
                            "color": "onSurface"
                          }
                        }
                      },
                      "events": {
                        "onSubmit": [
                          {
                            "state": {
                              "id": "search_done",
                              "input": {
                                "focused": ""
                              }
                            }
                          }
                        ]
                      }
                    },
                    {
                      "id": "category_control",
                      "type": "conditional",
                      "context": {
                        "_condition": "{{ ${mode} == 'Phrases' }}",
                        "_trueComponent": {
                          "id": "category_picker",
                          "type": "picker",
                          "context": {
                            "_label": "Category",
                            "_selection": "${category}",
                            "_options": [
                              "All categories",
                              "Radio basics",
                              "Clarification",
                              "Ground",
                              "Departure & arrival",
                              "En route",
                              "Urgency & distress"
                            ]
                          },
                          "style": {
                            "picker": "menu",
                            "layout": {
                              "minHeight": 44,
                              "maxWidth": "infinity"
                            },
                            "common": {
                              "foreground": {
                                "color": "onSurface"
                              }
                            }
                          }
                        }
                      }
                    },
                    {
                      "id": "collection_hint",
                      "type": "label",
                      "context": {
                        "_title": "{{ ${mode} == 'Alphabet' ? '26 letters • CAPITALS mark stressed syllables' : (${mode} == 'Phrases' ? '25 expressions • Tap a phrase for usage' : 'Starred entries • Stored on this device') }}",
                        "_image": "{{ ${mode} == 'Alphabet' ? 'sf://textformat.abc' : (${mode} == 'Phrases' ? 'sf://bubble.left.and.bubble.right' : 'sf://star.fill') }}"
                      },
                      "style": {
                        "common": {
                          "font": "caption",
                          "foreground": {
                            "color": "onSurfaceVariant"
                          }
                        }
                      }
                    }
                  ]
                },
                {
                  "id": "feedback_card",
                  "type": "conditional",
                  "context": {
                    "_condition": "{{ ${loading} || notEmpty(${status}) }}",
                    "_trueComponent": {
                      "id": "feedback_surface",
                      "type": "vstack",
                      "context": {
                        "_spacing": 10,
                        "_alignment": "leading"
                      },
                      "style": {
                        "layout": {
                          "maxWidth": "infinity",
                          "padding": 18
                        },
                        "common": {
                          "background": {
                            "color": "surfaceVariant"
                          },
                          "foreground": {
                            "color": "onSurfaceVariant"
                          },
                          "cornerRadius": 16
                        },
                        "animation": {
                          "kind": "spring",
                          "value": "${canUndo}"
                        }
                      },
                      "children": [
                        {
                          "id": "feedback_text",
                          "type": "label",
                          "context": {
                            "_image": "{{ ${saveError} ? 'sf://exclamationmark.triangle' : 'sf://star' }}",
                            "_title": "{{ ${loading} ? 'Loading your favorites…' : ${status} }}"
                          },
                          "style": {
                            "common": {
                              "font": "caption",
                              "foreground": {
                                "color": "onSurfaceVariant"
                              }
                            }
                          }
                        },
                        {
                          "id": "feedback_actions",
                          "type": "hstack",
                          "context": {
                            "_spacing": 12
                          },
                          "children": [
                            {
                              "id": "undo_visible",
                              "type": "conditional",
                              "context": {
                                "_condition": "${canUndo}",
                                "_trueComponent": {
                                  "id": "undo_favorite",
                                  "type": "button",
                                  "children": [
                                    {
                                      "id": "undo_label",
                                      "type": "label",
                                      "context": {
                                        "_title": "Undo",
                                        "_image": "sf://arrow.uturn.backward"
                                      },
                                      "style": {
                                        "common": {
                                          "foreground": {
                                            "color": "onSurfaceVariant"
                                          }
                                        }
                                      }
                                    }
                                  ],
                                  "style": {
                                    "layout": {
                                      "minHeight": 44
                                    },
                                    "button": {
                                      "standard": {
                                        "type": "bordered",
                                        "shape": "capsule"
                                      }
                                    }
                                  },
                                  "events": {
                                    "onTap": [
                                      {
                                        "state": {
                                          "id": "undo_change",
                                          "input": {
                                            "favorites": "${previousFavorites}",
                                            "canUndo": false,
                                            "focused": "",
                                            "status": "Restoring favorites…"
                                          },
                                          "output": {
                                            "success": [
                                              {
                                                "template": {
                                                  "id": "undo_persist",
                                                  "input": "persist_favorites"
                                                }
                                              }
                                            ]
                                          }
                                        }
                                      }
                                    ]
                                  }
                                }
                              }
                            },
                            {
                              "id": "retry_visible",
                              "type": "conditional",
                              "context": {
                                "_condition": "${saveError}",
                                "_trueComponent": {
                                  "id": "retry_save",
                                  "type": "button",
                                  "children": [
                                    {
                                      "id": "retry_label",
                                      "type": "label",
                                      "context": {
                                        "_title": "Retry save",
                                        "_image": "sf://arrow.clockwise"
                                      },
                                      "style": {
                                        "common": {
                                          "foreground": {
                                            "color": "onSurfaceVariant"
                                          }
                                        }
                                      }
                                    }
                                  ],
                                  "style": {
                                    "layout": {
                                      "minHeight": 44
                                    },
                                    "button": {
                                      "standard": {
                                        "type": "bordered",
                                        "shape": "capsule"
                                      }
                                    }
                                  },
                                  "events": {
                                    "onTap": [
                                      {
                                        "template": {
                                          "id": "retry_persist",
                                          "input": "persist_favorites"
                                        }
                                      }
                                    ]
                                  }
                                }
                              }
                            }
                          ]
                        }
                      ]
                    }
                  }
                },
                {
                  "id": "reference_content",
                  "type": "vstack",
                  "context": {
                    "_spacing": 12,
                    "_alignment": "leading"
                  },
                  "style": {
                    "layout": {
                      "maxWidth": "infinity"
                    }
                  },
                  "children": [
                    {
                      "id": "result_summary",
                      "type": "text",
                      "context": {
                        "_text": "{{ cast(count(@{results}), 'str') + (${mode} == 'Alphabet' ? ' letters' : ' entries') }}"
                      },
                      "style": {
                        "common": {
                          "font": {
                            "kind": "caption",
                            "weight": "semibold"
                          },
                          "foreground": {
                            "color": "secondary"
                          }
                        }
                      }
                    },
                    {
                      "id": "no_results",
                      "type": "conditional",
                      "context": {
                        "_condition": "{{ empty(@{results}) }}",
                        "_trueComponent": {
                          "id": "empty_card",
                          "type": "vstack",
                          "context": {
                            "_spacing": 12
                          },
                          "style": {
                            "layout": {
                              "maxWidth": "infinity",
                              "padding": 24
                            },
                            "common": {
                              "background": {
                                "color": "surface"
                              },
                              "foreground": {
                                "color": "onSurface"
                              },
                              "cornerRadius": 18
                            },
                            "shadow": {
                              "color": "#000000",
                              "radius": 4,
                              "x": 0,
                              "y": 2
                            }
                          },
                          "children": [
                            {
                              "id": "empty_icon",
                              "type": "image",
                              "context": {
                                "_source": "{{ ${mode} == 'Favorites' ? 'sf://star' : 'sf://magnifyingglass' }}"
                              },
                              "style": {
                                "layout": {
                                  "width": 32,
                                  "height": 32
                                },
                                "common": {
                                  "foreground": {
                                    "color": "onSurface"
                                  }
                                }
                              }
                            },
                            {
                              "id": "empty_message",
                              "type": "text",
                              "context": {
                                "_text": "{{ ${mode} == 'Favorites' && empty(${favorites}) ? 'Keep useful calls close.' : 'No matching reference entries.' }}"
                              },
                              "style": {
                                "common": {
                                  "font": "headline",
                                  "foreground": {
                                    "color": "onSurface"
                                  }
                                }
                              }
                            },
                            {
                              "id": "empty_hint",
                              "type": "text",
                              "context": {
                                "_text": "{{ ${mode} == 'Favorites' && empty(${favorites}) ? 'Star a letter or phrase to find it here next time.' : 'Try a shorter search or reset your filters.' }}"
                              },
                              "style": {
                                "common": {
                                  "font": "subheadline",
                                  "foreground": {
                                    "color": "onSurfaceVariant"
                                  }
                                }
                              }
                            },
                            {
                              "id": "empty_reset",
                              "type": "button",
                              "children": [
                                {
                                  "id": "empty_reset_label",
                                  "type": "label",
                                  "context": {
                                    "_title": "{{ ${mode} == 'Favorites' && empty(${favorites}) ? 'Browse alphabet' : 'Reset filters' }}",
                                    "_image": "sf://arrow.clockwise"
                                  }
                                }
                              ],
                              "style": {
                                "layout": {
                                  "minHeight": 44
                                },
                                "button": {
                                  "standard": {
                                    "type": "borderedProminent",
                                    "shape": "capsule"
                                  }
                                }
                              },
                              "events": {
                                "onTap": [
                                  {
                                    "state": {
                                      "id": "reset_filters",
                                      "input": {
                                        "query": "",
                                        "category": "All categories",
                                        "mode": "{{ ${mode} == 'Favorites' && empty(${favorites}) ? 'Alphabet' : ${mode} }}",
                                        "focused": ""
                                      }
                                    }
                                  }
                                ]
                              }
                            }
                          ]
                        }
                      }
                    },
                    {
                      "id": "reference_rows",
                      "type": "dynamic",
                      "context": {
                        "_data": "@{results}"
                      },
                      "prototype": {
                        "id": "reference_row",
                        "type": "hstack",
                        "context": {
                          "_spacing": 12,
                          "_alignment": "center"
                        },
                        "style": {
                          "layout": {
                            "maxWidth": "infinity",
                            "padding": 18
                          },
                          "common": {
                            "background": {
                              "color": "surface"
                            },
                            "foreground": {
                              "color": "onSurface"
                            },
                            "cornerRadius": 18
                          },
                          "shadow": {
                            "color": "#000000",
                            "radius": 3,
                            "x": 0,
                            "y": 2
                          }
                        },
                        "children": [
                          {
                            "id": "entry_kind",
                            "type": "conditional",
                            "style": {
                              "layout": {
                                "maxWidth": "infinity",
                                "alignment": "leading"
                              }
                            },
                            "context": {
                              "_condition": "{{ @{item.kind} == 'Alphabet' }}",
                              "_trueComponent": {
                                "id": "letter_row",
                                "type": "hstack",
                                "context": {
                                  "_spacing": 14
                                },
                                "children": [
                                  {
                                    "id": "letter_tile",
                                    "type": "text",
                                    "context": {
                                      "_text": "@{item.letter}"
                                    },
                                    "style": {
                                      "layout": {
                                        "width": 48,
                                        "height": 56
                                      },
                                      "common": {
                                        "font": {
                                          "kind": "title",
                                          "weight": "bold"
                                        },
                                        "background": {
                                          "color": "#183B53"
                                        },
                                        "foreground": {
                                          "color": "white"
                                        },
                                        "cornerRadius": 12
                                      }
                                    }
                                  },
                                  {
                                    "id": "letter_words",
                                    "type": "vstack",
                                    "context": {
                                      "_spacing": 4,
                                      "_alignment": "leading"
                                    },
                                    "style": {
                                      "layout": {
                                        "maxWidth": "infinity",
                                        "alignment": "leading"
                                      }
                                    },
                                    "children": [
                                      {
                                        "id": "letter_name",
                                        "type": "text",
                                        "context": {
                                          "_text": "@{item.title}"
                                        },
                                        "style": {
                                          "common": {
                                            "font": {
                                              "kind": "title3",
                                              "weight": "semibold"
                                            },
                                            "foreground": {
                                              "color": "onSurface"
                                            }
                                          }
                                        }
                                      },
                                      {
                                        "id": "letter_pronunciation",
                                        "type": "text",
                                        "context": {
                                          "_text": "@{item.subtitle}"
                                        },
                                        "style": {
                                          "common": {
                                            "font": "subheadline",
                                            "foreground": {
                                              "color": "onSurfaceVariant"
                                            }
                                          }
                                        }
                                      }
                                    ]
                                  }
                                ]
                              },
                              "_falseComponent": {
                                "id": "phrase_link",
                                "type": "link",
                                "destination": {
                                  "id": "phrase_detail",
                                  "type": "module",
                                  "state": {
                                    "focused": ""
                                  },
                                  "events": {
                                    "onAppear": [
                                      {
                                        "state": {
                                          "id": "dismiss_detail_keyboard",
                                          "input": {
                                            "focused": ""
                                          }
                                        }
                                      }
                                    ]
                                  },
                                  "children": [
                                    {
                                      "id": "detail_scroll",
                                      "type": "scroll",
                                      "style": {
                                        "layout": {
                                          "maxWidth": "infinity",
                                          "maxHeight": "infinity"
                                        }
                                      },
                                      "children": [
                                        {
                                          "id": "detail_stack",
                                          "type": "vstack",
                                          "context": {
                                            "_spacing": 20,
                                            "_alignment": "leading"
                                          },
                                          "style": {
                                            "layout": {
                                              "padding": 20,
                                              "maxWidth": "infinity"
                                            }
                                          },
                                          "children": [
                                            {
                                              "id": "detail_hero",
                                              "type": "vstack",
                                              "context": {
                                                "_spacing": 12,
                                                "_alignment": "leading"
                                              },
                                              "style": {
                                                "layout": {
                                                  "maxWidth": "infinity",
                                                  "padding": 22
                                                },
                                                "common": {
                                                  "background": {
                                                    "gradient": {
                                                      "linear": {
                                                        "colors": [
                                                          "#183B53",
                                                          "#102638"
                                                        ],
                                                        "startPoint": "topLeading",
                                                        "endPoint": "bottomTrailing"
                                                      }
                                                    }
                                                  },
                                                  "foreground": {
                                                    "color": "white"
                                                  },
                                                  "cornerRadius": 20
                                                },
                                                "shadow": {
                                                  "color": "#000000",
                                                  "radius": 8,
                                                  "x": 0,
                                                  "y": 4
                                                }
                                              },
                                              "children": [
                                                {
                                                  "id": "detail_category",
                                                  "type": "label",
                                                  "context": {
                                                    "_image": "sf://antenna.radiowaves.left.and.right",
                                                    "_title": "@{item.category}"
                                                  },
                                                  "style": {
                                                    "common": {
                                                      "font": "subheadline",
                                                      "foreground": {
                                                        "color": "white"
                                                      }
                                                    }
                                                  }
                                                },
                                                {
                                                  "id": "detail_phrase",
                                                  "type": "text",
                                                  "context": {
                                                    "_text": "@{item.title}"
                                                  },
                                                  "style": {
                                                    "common": {
                                                      "font": {
                                                        "kind": "largeTitle",
                                                        "weight": "bold"
                                                      },
                                                      "foreground": {
                                                        "color": "white"
                                                      }
                                                    }
                                                  }
                                                },
                                                {
                                                  "id": "detail_subtitle",
                                                  "type": "text",
                                                  "context": {
                                                    "_text": "@{item.subtitle}"
                                                  },
                                                  "style": {
                                                    "common": {
                                                      "font": "subheadline",
                                                      "foreground": {
                                                        "color": "white"
                                                      }
                                                    }
                                                  }
                                                }
                                              ]
                                            },
                                            {
                                              "id": "meaning_card",
                                              "type": "vstack",
                                              "context": {
                                                "_spacing": 12,
                                                "_alignment": "leading"
                                              },
                                              "style": {
                                                "layout": {
                                                  "maxWidth": "infinity",
                                                  "padding": 20
                                                },
                                                "common": {
                                                  "background": {
                                                    "color": "surface"
                                                  },
                                                  "foreground": {
                                                    "color": "onSurface"
                                                  },
                                                  "cornerRadius": 18
                                                },
                                                "shadow": {
                                                  "color": "#000000",
                                                  "radius": 3,
                                                  "x": 0,
                                                  "y": 2
                                                }
                                              },
                                              "children": [
                                                {
                                                  "id": "meaning_header",
                                                  "type": "label",
                                                  "context": {
                                                    "_title": "Meaning",
                                                    "_image": "sf://text.bubble"
                                                  },
                                                  "style": {
                                                    "common": {
                                                      "font": "headline",
                                                      "foreground": {
                                                        "color": "onSurface"
                                                      }
                                                    }
                                                  }
                                                },
                                                {
                                                  "id": "meaning_text",
                                                  "type": "text",
                                                  "context": {
                                                    "_text": "@{item.meaning}"
                                                  },
                                                  "style": {
                                                    "common": {
                                                      "font": "body",
                                                      "foreground": {
                                                        "color": "onSurface"
                                                      }
                                                    }
                                                  }
                                                }
                                              ]
                                            },
                                            {
                                              "id": "example_card",
                                              "type": "vstack",
                                              "context": {
                                                "_spacing": 12,
                                                "_alignment": "leading"
                                              },
                                              "style": {
                                                "layout": {
                                                  "maxWidth": "infinity",
                                                  "padding": 20
                                                },
                                                "common": {
                                                  "background": {
                                                    "color": "surface"
                                                  },
                                                  "foreground": {
                                                    "color": "onSurface"
                                                  },
                                                  "cornerRadius": 18
                                                },
                                                "shadow": {
                                                  "color": "#000000",
                                                  "radius": 3,
                                                  "x": 0,
                                                  "y": 2
                                                }
                                              },
                                              "children": [
                                                {
                                                  "id": "example_header",
                                                  "type": "label",
                                                  "context": {
                                                    "_title": "Wording example",
                                                    "_image": "sf://quote.bubble"
                                                  },
                                                  "style": {
                                                    "common": {
                                                      "font": "headline",
                                                      "foreground": {
                                                        "color": "onSurface"
                                                      }
                                                    }
                                                  }
                                                },
                                                {
                                                  "id": "example_text",
                                                  "type": "text",
                                                  "context": {
                                                    "_text": "@{item.example}"
                                                  },
                                                  "style": {
                                                    "common": {
                                                      "font": {
                                                        "kind": "body",
                                                        "weight": "medium"
                                                      },
                                                      "foreground": {
                                                        "color": "onSurface"
                                                      }
                                                    }
                                                  }
                                                },
                                                {
                                                  "id": "example_hint",
                                                  "type": "text",
                                                  "context": {
                                                    "_text": "Bracketed fields are placeholders, not a live clearance."
                                                  },
                                                  "style": {
                                                    "common": {
                                                      "font": "caption",
                                                      "foreground": {
                                                        "color": "onSurfaceVariant"
                                                      }
                                                    }
                                                  }
                                                }
                                              ]
                                            },
                                            {
                                              "id": "usage_card",
                                              "type": "vstack",
                                              "context": {
                                                "_spacing": 12,
                                                "_alignment": "leading"
                                              },
                                              "style": {
                                                "layout": {
                                                  "maxWidth": "infinity",
                                                  "padding": 20
                                                },
                                                "common": {
                                                  "background": {
                                                    "light": "#F4EADA",
                                                    "dark": "#332C21"
                                                  },
                                                  "foreground": {
                                                    "light": "#3B2D1A",
                                                    "dark": "#F4EADA"
                                                  },
                                                  "cornerRadius": 18
                                                },
                                                "shadow": {
                                                  "color": "#000000",
                                                  "radius": 3,
                                                  "x": 0,
                                                  "y": 2
                                                }
                                              },
                                              "children": [
                                                {
                                                  "id": "usage_header",
                                                  "type": "label",
                                                  "context": {
                                                    "_title": "Keep in mind",
                                                    "_image": "sf://exclamationmark.triangle"
                                                  },
                                                  "style": {
                                                    "common": {
                                                      "font": "headline",
                                                      "foreground": {
                                                        "light": "#3B2D1A",
                                                        "dark": "#F4EADA"
                                                      }
                                                    }
                                                  }
                                                },
                                                {
                                                  "id": "usage_text",
                                                  "type": "text",
                                                  "context": {
                                                    "_text": "@{item.note}"
                                                  },
                                                  "style": {
                                                    "common": {
                                                      "font": "body",
                                                      "foreground": {
                                                        "light": "#3B2D1A",
                                                        "dark": "#F4EADA"
                                                      }
                                                    }
                                                  }
                                                }
                                              ]
                                            },
                                            {
                                              "id": "detail_footer",
                                              "type": "text",
                                              "context": {
                                                "_text": "General ICAO-style radiotelephony reference. Consult current ICAO Annex 10 Volume II, PANS-ATM (Doc 4444), your AIP and operator procedures. Local wording and requirements may differ."
                                              },
                                              "style": {
                                                "common": {
                                                  "font": "caption",
                                                  "foreground": {
                                                    "color": "secondary"
                                                  }
                                                }
                                              }
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                "children": [
                                  {
                                    "id": "phrase_preview",
                                    "type": "vstack",
                                    "context": {
                                      "_spacing": 6,
                                      "_alignment": "leading"
                                    },
                                    "style": {
                                      "layout": {
                                        "maxWidth": "infinity",
                                        "alignment": "leading",
                                        "minHeight": 64
                                      }
                                    },
                                    "children": [
                                      {
                                        "id": "phrase_category",
                                        "type": "text",
                                        "context": {
                                          "_text": "@{item.category}"
                                        },
                                        "style": {
                                          "common": {
                                            "font": "caption",
                                            "foreground": {
                                              "color": "onSurfaceVariant"
                                            }
                                          }
                                        }
                                      },
                                      {
                                        "id": "phrase_heading",
                                        "type": "label",
                                        "context": {
                                          "_title": "@{item.title}",
                                          "_image": "sf://chevron.right"
                                        },
                                        "style": {
                                          "common": {
                                            "font": {
                                              "kind": "headline",
                                              "weight": "bold"
                                            },
                                            "foreground": {
                                              "color": "onSurface"
                                            }
                                          }
                                        }
                                      },
                                      {
                                        "id": "phrase_subtitle",
                                        "type": "text",
                                        "context": {
                                          "_text": "@{item.subtitle}"
                                        },
                                        "style": {
                                          "common": {
                                            "font": "subheadline",
                                            "foreground": {
                                              "color": "onSurfaceVariant"
                                            }
                                          }
                                        }
                                      }
                                    ]
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "id": "favorite_button",
                            "type": "button",
                            "style": {
                              "layout": {
                                "minWidth": 48,
                                "minHeight": 56,
                                "padding": 6
                              },
                              "common": {
                                "disabled": "${loading}",
                                "background": "{{ contains(${favorites}, @{item.id}) ? { 'color': '#D9EAD6' } : { 'color': 'surfaceVariant' } }}",
                                "foreground": "{{ contains(${favorites}, @{item.id}) ? { 'color': '#173727' } : { 'color': 'onSurfaceVariant' } }}",
                                "cornerRadius": 12
                              },
                              "animation": {
                                "kind": "spring",
                                "value": "{{ contains(${favorites}, @{item.id}) }}"
                              }
                            },
                            "children": [
                              {
                                "id": "favorite_content",
                                "type": "vstack",
                                "context": {
                                  "_spacing": 4
                                },
                                "children": [
                                  {
                                    "id": "favorite_star",
                                    "type": "image",
                                    "context": {
                                      "_source": "{{ contains(${favorites}, @{item.id}) ? 'sf://star.fill' : 'sf://star' }}"
                                    },
                                    "style": {
                                      "layout": {
                                        "width": 20,
                                        "height": 20
                                      },
                                      "common": {
                                        "foreground": "{{ contains(${favorites}, @{item.id}) ? { 'color': '#173727' } : { 'color': 'onSurfaceVariant' } }}"
                                      }
                                    }
                                  },
                                  {
                                    "id": "favorite_caption",
                                    "type": "text",
                                    "context": {
                                      "_text": "{{ contains(${favorites}, @{item.id}) ? 'Saved' : 'Save' }}"
                                    },
                                    "style": {
                                      "common": {
                                        "font": "caption2",
                                        "foreground": "{{ contains(${favorites}, @{item.id}) ? { 'color': '#173727' } : { 'color': 'onSurfaceVariant' } }}"
                                      }
                                    }
                                  }
                                ]
                              }
                            ],
                            "events": {
                              "onTap": [
                                {
                                  "template": {
                                    "id": "favorite_toggle_call",
                                    "input": "toggle_favorite"
                                  }
                                }
                              ]
                            }
                          }
                        ]
                      }
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}