/* =============================================================================
 * app.css - the shared component layer for every Nayive app.
 *
 * WHAT THIS IS
 *   Nayive is nine small single-page apps that must feel like one product. The
 *   colour tokens and a few widgets already lived in shared/theme.css; this
 *   file adds the rest of the common UI - the app shell, the header, the icon
 *   button, the dialog, the form field, pills and cards - so an app's own
 *   <style> block only has to hold what is genuinely unique to that app.
 *
 *   THIS FILE (plus theme.css and the ui.js header comment) IS the Nayive style
 *   guide - the only one. Each block below is preceded by a comment that says
 *   what the component is, when to use it, and the rules it must follow. If you
 *   are building or changing Nayive UI, read the comment for the component you
 *   are touching. There is no separate style-guide document to keep in sync.
 *
 * HOW TO LOAD  (in every app's <head>, in this order)
 *     <meta name="theme-color" content="#1E1F23">           <!-- the dark --bg -->
 *     <link rel="stylesheet" href="../shared/theme.css">    <!-- tokens first -->
 *     <link rel="stylesheet" href="../shared/app.css">
 *     <script>try{ if(localStorage.getItem('balata-theme')==='light')
 *         document.documentElement.setAttribute('data-theme','light'); }catch(e){}</script>
 *     <script src="../shared/theme.js" defer></script>      <!-- scheme toggle + sync -->
 *     <script src="../shared/ui.js"></script>               <!-- NayiveUI: sheets, toast, buttons -->
 *     ... then the app's own <style> ...
 *   The inline script applies the saved scheme before first paint (no flash).
 *   The app's <style> comes last, so on an equal-specificity clash the app
 *   wins - use that only for real per-app layout, never to restyle a shared
 *   component into a different look. PWA manifests set theme_color /
 *   background_color to #1E1F23.
 *
 * THE TOKENS  (defined in theme.css - use the name, never the literal)
 *   colour     --bg --card --card2 --line --text --text-dim --text-faint
 *              --accent --on-accent --danger --link --ok --warn --busy --shadow
 *              (each has a one-line "what it's for" comment in theme.css)
 *   type       --font-sans --font-mono
 *   radius     --radius-s (8) --radius-m (12) --radius-l (16) --radius-pill (999)
 *   spacing    --space-1..5  (4 8 12 16 24)
 *   elevation  --elev-card --elev-dialog --scrim
 *   motion     --tr-fast (colour) --tr-move (transform)
 *
 * TYPE SIZES  (rem; weight 700 where noted)
 *   app title (h1 / .app-title) 1.1  --accent 700    dialog title (h2)  1.15  700
 *   body / list rows            0.9 - 0.95           field label / meta 0.8  --text-dim
 *   section label               0.72 700 uppercase, letter-spacing 0.06em, --text-dim
 *
 * GLOBAL RULES
 *   - Never write a hex colour, a raw box-shadow, or an off-scale corner radius
 *     in an app. Add the value to theme.css if the scale is missing something.
 *   - Hover / pressed tints use color-mix(in srgb, var(--text) N%, transparent)
 *     so they flip light-on-dark and dark-on-light. Never a fixed rgba().
 *   - An accent fill means "active / selected / primary". It is not a hover
 *     colour - hover is a neutral --text tint.
 *   - Every icon-only control needs a Spanish `title` and an `aria-label`.
 *   - Every date shown to a person is yyyy-mm-dd. No locale or month-name form.
 *   - All user-facing text is Spanish; app names keep their short label
 *     ("Calc", "Drive", ...).
 *   - A dialog closes on its own × / ✓ buttons and the Esc key only - never on
 *     a click on the backdrop.
 *
 * PER-APP OVERRIDES
 *   An app's <style> may carry a few small overrides of the rules here - a
 *   page that hides its own scroll, calc's tinted toolbar, trip's two-column
 *   layout, the compose-bar submit in tasks, the entry-screen styling in
 *   login.html / admin.html, the 30-32px "toolbar button" that calc / text /
 *   write use instead of .icon-btn. Each such override carries a one-line
 *   comment saying why. That comment is the record; there is no central list.
 * ===========================================================================*/


/* -----------------------------------------------------------------------------
 * BASE / RESET
 *
 * border-box everywhere. The page never scrolls sideways. The body carries the
 * UI font, the primary text colour and the page background so an app's <body>
 * rule can be deleted. Links are the accent-independent --link blue, underline
 * on hover only.
 * ---------------------------------------------------------------------------*/
*,
*::before,
*::after            { box-sizing: border-box; }

html               { overflow-x: hidden; overflow-y: auto; }

body
{
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    -webkit-tap-highlight-color: transparent;
}

a                  { color: var(--link); text-decoration: none; }
a:hover            { text-decoration: underline; opacity: 0.85; }


/* -----------------------------------------------------------------------------
 * APP SHELL - two layouts, pick one per app
 *
 * A) TOOL SHELL  (.app)  - calc, calendar, drive, text, write, planner
 *    A full-height flex column: a fixed .topbar on top, the work area (a grid,
 *    an editor, a map) fills the rest and does its own scrolling. The page
 *    background is --bg.
 *
 * B) CARD SHELL  (.page > .page-inner > .card)  - tasks, contact
 *    A single centred column that reads like a sheet of paper. Max width
 *    460px. On a real phone (<=480px) the card loses its border, radius and
 *    shadow and goes edge to edge. The edge-to-edge rule is scoped to
 *    .page > .page-inner > .card, so a standalone .card (login, a dialog-free
 *    panel) keeps its box at every width.
 *
 *    trip is a card app too but runs its own two-column variant (.trip-panel,
 *    not .card): the list on the left, a sticky route map on the right on a
 *    wide viewport.
 *
 * Do not mix A and B. An app is either a tool or a list/document.
 * ---------------------------------------------------------------------------*/
.app
{
    display: flex;
    flex-direction: column;
    height: 100%;
}

.page
{
    display: flex;
    justify-content: center;
    width: 100%;
    min-height: 100vh;
    padding: 28px 14px;
}

.page-inner        { width: 100%; max-width: 460px; }

.card
{
    padding: 20px 16px 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-l);
    box-shadow: var(--elev-card);
}

@media (max-width: 480px)
{
    .page                        { padding: 0; }
    .page > .page-inner          { max-width: 100%; }
    .page > .page-inner > .card
    {
        min-height: 100vh;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }
}


/* -----------------------------------------------------------------------------
 * HEADER
 *
 * Same shape in every app, same order left to right:
 *
 *     [.app-icon]  [<h1> app name]  ... app controls ...  [.sync-indicator]
 *
 * - .topbar is the tool-shell header. It is ONE row while everything fits; when
 *   the viewport is too narrow the button bar wraps onto the next line(s) - the
 *   same way a toolbar overflows - and the title always stays fully readable
 *   (it wraps its own text before it is ever clipped). Divider underneath.
 *   Card-shell apps (.header) use a plain flex row with the same parts and the
 *   same wrap behaviour, and `margin-bottom: var(--space-4)` instead of a border.
 * - .app-icon: an inline SVG in --accent. Render it 20px in a .topbar, 26px in
 *   a card header.
 * - The <h1> (or .app-title) is ALWAYS --accent, 1.1rem, weight 700, no margin.
 *   Do not colour it --text; do not size it per app. Never give it
 *   `text-overflow: ellipsis` - the title is not allowed to be truncated.
 * - The sync dot is ALWAYS the last child of the header.
 * - Header buttons are .icon-btn (see below). The primary "new" one gets
 *   .accent; a destructive one gets .danger.
 * - Wrap the trailing controls (every button + the sync dot) in a
 *   .topbar-actions / .header-actions group so the whole bar drops to the next
 *   line together, instead of one lone button clinging to the title's line.
 *   A header with just a control or two can skip the wrapper.
 * ---------------------------------------------------------------------------*/
.topbar
{
    display: flex;
    align-items: center;
    flex-wrap: wrap;              /* a long title / crowded bar wraps to a second row, never truncates */
    gap: 2px;
    row-gap: 4px;                 /* breathing room between wrapped rows */
    flex: 0 0 auto;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;            /* safety net: a single un-wrappable wide child still scrolls */
}

.topbar h1,
.app-title
{
    flex: 0 1 auto;             /* sit at its natural width; wrap its text before shrinking further */
    min-width: min-content;    /* wrap the title's own text - never clip it */
    margin: 0 10px 0 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    white-space: normal;
}

.app-icon          { flex: 0 0 auto; color: var(--accent); }

/* The app icon + name double as a button back to the launcher (wired in
   shared/ui.js). Only the cursor + a light hover hint at it - the layout is
   unchanged. Real controls inside the header keep their own action. */
.nayive-home-link                    { cursor: pointer; }
.topbar h1.nayive-home-link:hover,
.header h1.nayive-home-link:hover,
.app-title.nayive-home-link:hover    { text-decoration: underline; text-underline-offset: 3px; }
.app-icon.nayive-home-link:hover     { opacity: 0.7; }

/* The trailing button bar, kept together so it wraps as one unit (see above). */
.topbar-actions,
.header-actions
{
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
    margin-left: auto;          /* hug the right edge while it shares the title's line */
}

/* Card-shell header: same parts, no divider. */
.header
{
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    row-gap: 4px;
    margin-bottom: var(--space-4);
}
.header h1,
.header .app-title
{
    flex: 1 1 auto;
    min-width: min-content;     /* wrap the title, never clip it; buttons wrap below instead */
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    white-space: normal;
}


/* -----------------------------------------------------------------------------
 * FOLDER CRUMB  (.crumb)  and  VIEW BAR INFO  (.bar-info)
 *
 * Folder-backed viewers (Photos, Music, Movies) share ONE header layout:
 *
 *   row 1   [icon] <h1>   [.crumb  (folder) path]   ............   [sync dot]
 *   row 2   [.bar-info  item counts / genres / totals]
 *   row 3   a toolbar: [ view / filter buttons ] [.tb-end: search, reload, help] ....
 *
 * - .crumb is a button in the .topbar. It carries a folder icon + the folder
 *   path and opens the change-folder picker. It shows the PATH ONLY - never a
 *   count, never a hint. Put an <svg> then a <span> inside it.
 * - .bar-info is the ONE place for item counts, genres, totals and the like.
 *   It is the LAST child of the .topbar and rides its own row, flush under the
 *   title + crumb. Empty -> hidden. Never repeat the folder path here.
 * - .tb-end groups the search field + reload + help right after the view/filter
 *   buttons. Only the sync dot stays up in the header. On a phone
 *   the search field collapses behind a magnifier (.search-toggle); tapping it
 *   toggles `.show` on the field.
 * ---------------------------------------------------------------------------*/
.crumb
{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 1 auto;
    min-width: 0;
    margin: 0 var(--space-2) 0 0;
    padding: 4px 10px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--card2);
    color: var(--text-dim);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background-color var(--tr-fast), color var(--tr-fast);
}
.crumb svg    { width: 14px; height: 14px; flex: 0 0 auto; }
.crumb span   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb:hover  { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }
.crumb:empty  { display: none; }

.bar-info
{
    flex: 1 0 100%;               /* own row, full width, flush under title + crumb */
    margin: 3px 0 0;
    text-align: left;
    font-size: 0.8rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
.bar-info:empty { display: none; }

/* The trailing group of the view/filter toolbar: search + reload + help.
   Sits right after the view/filter buttons - not pushed to the right edge. */
.tb-end
{
    display: flex;
    align-items: center;
    gap: 2px;
}
/* Desktop shows the text field, so the magnifier stays hidden. Each app's own
   narrow-viewport @media flips this (field -> .search-toggle) at its breakpoint. */
.search-toggle { display: none; }


/* -----------------------------------------------------------------------------
 * ICON BUTTON  (.icon-btn)  - the workhorse control
 *
 * A round, borderless, icon-only button used in headers, toolbars and rows.
 *
 *   size        36px (use .icon-btn.sm = 30px for dense toolbars)
 *   shape       circle, no border, transparent background
 *   colour      --text-dim at rest, --text on hover
 *   hover       a neutral --text 9% wash (NEVER an accent tint)
 *   pressed     --text 14%
 *   focus       a visible --accent ring for keyboard users
 *   disabled    opacity 0.45, no pointer, no hover
 *
 * The SVG inside: 24x24 viewBox, stroke="currentColor", fill="none",
 * stroke-width ~2, round caps and joins (Feather style). Rendered 18-20px.
 *
 * MODIFIERS
 *   .accent   solid --accent fill, --on-accent icon. The "new item" button.
 *   .danger   a DELETE button: a --danger icon at rest (not just on hover);
 *             hover adds a faint --danger wash. Borderless like every other
 *             .icon-btn - the red icon alone marks it. Matches the dialog
 *             .btn-danger so "delete" looks the same everywhere.
 *   .is-active  solid --accent fill for a toggle that is currently on
 *               (e.g. the calendar view switch).
 * ---------------------------------------------------------------------------*/
.icon-btn
{
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: background-color var(--tr-fast), color var(--tr-fast);
}
.icon-btn svg           { width: 19px; height: 19px; display: block; }
.icon-btn:hover         { background: color-mix(in srgb, var(--text) 9%, transparent); color: var(--text); }
.icon-btn:active        { background: color-mix(in srgb, var(--text) 14%, transparent); }
.icon-btn:focus         { outline: none; }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn:disabled      { opacity: 0.45; cursor: default; background: transparent; color: var(--text-dim); }

.icon-btn.sm            { width: 30px; height: 30px; }
.icon-btn.sm svg        { width: 17px; height: 17px; }

.icon-btn.accent        { background: var(--accent); color: var(--on-accent); }
.icon-btn.accent:hover  { background: var(--accent); filter: brightness(1.08); }

.icon-btn.danger        { color: var(--danger); }
.icon-btn.danger:hover  { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }

.icon-btn.is-active         { background: var(--accent); color: var(--on-accent); }
.icon-btn.is-active:hover   { background: var(--accent); }

/* TOOLBAR BUTTON - a related but distinct component, NOT styled here.
 * calc (.fmt-btn), text (.tb-btn) and write (#writeTools .icon-btn) each define
 * their own: a 30-32px rounded SQUARE (--radius-s), --text-dim icon, and an
 * ACCENT-tinted hover (color-mix(--accent 14%)) / active (--accent 24%) because
 * the button acts on document content, not app chrome. It stays per-app on
 * purpose - the three toolbars differ enough that a shared class earns nothing.
 * If you add a fourth, copy one of the existing three. */


/* -----------------------------------------------------------------------------
 * TEXT BUTTON  (.text-btn)  - a wide call to action
 *
 * Use when a button needs a word, not just an icon: "Añadir", "Importar",
 * "Guardar cambios" on a full-width row. Accent fill, --on-accent text.
 * For a dialog's confirm / cancel row use the round .btn set from theme.css
 * instead (see DIALOG BUTTONS below).
 *
 *   .text-btn.ghost   quiet version: no fill, --line border, --text-dim text.
 *   .text-btn.dashed  an "add another" affordance: dashed accent border on a
 *                     faint accent wash (trip's "Añadir etapa").
 * ---------------------------------------------------------------------------*/
.text-btn
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-s);
    background: var(--accent);
    color: var(--on-accent);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--tr-fast), background-color var(--tr-fast);
}
.text-btn:hover     { filter: brightness(1.08); }
.text-btn:active    { filter: brightness(0.94); }
.text-btn:disabled  { opacity: 0.45; cursor: default; filter: none; }

.text-btn.ghost
{
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--line);
}
.text-btn.ghost:hover { background: color-mix(in srgb, var(--text) 9%, transparent); color: var(--text); filter: none; }

.text-btn.dashed
{
    width: 100%;
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    color: var(--accent);
    border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
}
.text-btn.dashed:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); filter: none; }


/* -----------------------------------------------------------------------------
 * DIALOG BUTTONS  (.sheet-actions / .btn / .btn-*)  - defined in theme.css
 *
 * The bottom row of a dialog is a right-aligned line of round 44px icon-only
 * buttons. Mark them up declaratively and let shared/ui.js fill in class + SVG:
 *
 *     <div class="sheet-actions">
 *       <button data-act="close"   title="Cancelar"></button>
 *       <button data-act="primary" title="Guardar"></button>
 *     </div>
 *
 * Roles: close (X) - primary (check) - danger (trash) - ghost (help).
 * .sheet-actions-left pins a delete button to the far left.
 *
 * ONE ICON PER MEANING (dialogs and toolbars alike):
 *   check   = confirm / apply / save / rename / create - always, any verb.
 *   saveas  = "save as a new copy" (check + a small +). Nothing else.
 *   trash   = a destructive confirm. Never looks like a save.
 *   A different verb keeps its own glyph: edit (opens a form), search (runs a
 *   query), plus (a compose bar).
 *
 * A dialog whose only action is "close" has NO bottom row - ui.js moves the
 * lone close button to the top-right corner as .sheet-close.
 * ---------------------------------------------------------------------------*/


/* -----------------------------------------------------------------------------
 * DIALOG / SHEET  (.sheet-backdrop > .sheet)
 *
 *     <div class="sheet-backdrop" id="fooBackdrop">
 *       <div class="sheet">
 *         <h2>Título</h2>
 *         ... .field rows ...
 *         <div class="sheet-actions"> ... </div>
 *       </div>
 *     </div>
 *
 * - The backdrop is a fixed --scrim layer; add .open (or NayiveUI.open(id)) to
 *   show it. It centres the sheet on desktop.
 * - The sheet is a --card panel, --radius-l corners, --elev-dialog shadow,
 *   scrolls inside at tall content. Default max-width 460px; add .sheet--wide
 *   for 560px when the content is genuinely wide (a table, a wide form).
 * - .sheet--pack shrinks the dialog to the width its content actually needs
 *   (clamped to [300px, 460px] and to the screen). NayiveUI.setOpen() runs the
 *   fit on open; NayiveUI.pack(el, {min,max}) does it by hand with custom bounds.
 *   Use it for short forms (a few selects / a checkbox) that look lost at 460px.
 * - CLOSING: only the × / ✓ buttons and the Esc key close a dialog. Never wire
 *   a click on the backdrop to close - it loses half-typed input.
 * - The backdrop is a flex box that centres the sheet both ways, so every
 *   dialog sits in the middle of the visible area on any screen size.
 * ---------------------------------------------------------------------------*/
.sheet-backdrop
{
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: var(--scrim);
}
.sheet-backdrop.open { display: flex; }

.sheet
{
    position: relative;
    width: 100%;
    max-width: 460px;
    max-height: 92vh;
    overflow-y: auto;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-l);
    box-shadow: var(--elev-dialog);
}
.sheet--wide       { max-width: 560px; }

/* Content-fit width. JS (NayiveUI) sets an exact px width on open; this is the
 * pre-JS / fallback look so the sheet never flashes at the full 460px first. */
.sheet--pack       { width: max-content; min-width: 300px; }

.sheet h2
{
    margin: 0 0 14px;
    font-size: 1.15rem;
    font-weight: 700;
}

/* Body copy in a NayiveUI.confirm / NayiveUI.alert sheet (shared/ui.js). */
.sheet > p.dialog-text
{
    margin: 0 0 14px;
    color: var(--text-dim);
    line-height: 1.45;
    white-space: pre-wrap;
}
.sheet > p.dialog-text:last-of-type { margin-bottom: 4px; }

/* A dialog header row: a title on the left, one small control on the right
 * (an "all day" switch, a step counter). */
.sheet-header
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 2px 0 16px;
}
.sheet-header h2   { margin: 0; }

@media (max-width: 640px)
{
    /* Still a centred card on a phone - just let it use the full width and a
     * touch more height. The backdrop keeps centring it vertically. */
    .sheet { max-height: 90vh; }
}


/* -----------------------------------------------------------------------------
 * FORM FIELD  (.field)
 *
 *     <div class="field">
 *       <label for="x">Etiqueta</label>
 *       <input id="x" type="text">
 *     </div>
 *
 * - Label: 0.8rem, --text-dim, sentence case (NOT uppercase - that style is
 *   reserved for .section-label).
 * - Inputs, selects and textareas share one look: --card2 fill, --line border,
 *   --radius-s, 10px 11px padding, the page font at 1rem, no default outline.
 * - Focus shows a slightly stronger border (--text 30%). No glow, no colour
 *   change - the same treatment on every field in every app.
 * - Put two fields side by side by wrapping them in .field-row.
 *
 * SPECIFICITY: the input rules below are deliberately kept at their weakest
 * (`input, select, textarea`), so ANY rule an app already has - a
 * `.topbar-search`, a `.file-label-input`, a `.loc-input-wrap input` - still
 * wins. app.css only supplies the default for an otherwise-unstyled field.
 * When you sweep an app, delete its local copy of this look and let app.css
 * carry it.
 * ---------------------------------------------------------------------------*/
.field             { margin-bottom: 14px; }

.field label
{
    display: block;
    margin-bottom: 5px;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.field-row
{
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.field-row .field  { flex: 1 1 120px; min-width: 0; }

/* A field's control fills the row. Scoped to .field so it never stretches a
 * toolbar / search input that lives outside a form. */
.field input,
.field select,
.field textarea    { width: 100%; }

input,
select,
textarea
{
    padding: 10px 11px;
    font: inherit;
    font-size: 1rem;
    color: var(--text);
    background: var(--card2);
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    outline: none;
}
textarea           { resize: vertical; min-height: 54px; }

input:focus,
select:focus,
textarea:focus     { border-color: color-mix(in srgb, var(--text) 30%, transparent); }

::placeholder      { color: var(--text-faint); }

/* Browser autofill paints its own pale background + a hard border. Force the
 * themed look back. Chrome/Edge: the inset box-shadow is the only way to cover
 * the autofill background. Firefox: honours background-color on :autofill. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus
{
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 100px var(--card2) inset;
    caret-color: var(--text);
    border: 1px solid var(--line);
}
input:autofill { background-color: var(--card2); color: var(--text); }

/* Checkbox / radio / colour / file / range keep the browser's box - the field
 * look above is for text-like inputs only. */
input[type="checkbox"],
input[type="radio"],
input[type="color"],
input[type="file"],
input[type="range"]
{
    width: auto;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
    accent-color: var(--accent);
}


/* -----------------------------------------------------------------------------
 * PILL  (.pill)  and  TAG  (.tag)
 *
 * .pill  - a small rounded button, used for filters and mode switches. At rest
 *          it is a quiet --card2 chip; add .is-active for the accent state.
 * .tag   - the same shape but read-only (a metadata chip on a card). No hover,
 *          no active state, default cursor.
 * ---------------------------------------------------------------------------*/
.pill
{
    padding: 7px 14px;
    font-family: inherit;
    font-size: 0.77rem;
    color: var(--text-dim);
    background: var(--card2);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: opacity var(--tr-fast), background-color var(--tr-fast);
}
.pill:hover        { opacity: 0.85; }
.pill.is-active
{
    color: var(--on-accent);
    background: var(--accent);
    border-color: var(--accent);
}

.tag
{
    padding: 4px 10px;
    font-size: 0.74rem;
    color: var(--text-dim);
    background: var(--card2);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
}


/* -----------------------------------------------------------------------------
 * CARD ROW  (.card-row)
 *
 * A row in a list - a file in Drive, a trip, a saved document. A --card2
 * surface with --line border and --radius-m corners. Hover firms up the
 * border; .is-selected fills it with accent and flips the text.
 * ---------------------------------------------------------------------------*/
.card-row
{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text);
    background: var(--card2);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    transition: border-color var(--tr-fast), background-color var(--tr-fast);
}
.card-row:hover        { border-color: color-mix(in srgb, var(--text) 22%, transparent); }
.card-row.is-selected  { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }


/* -----------------------------------------------------------------------------
 * SECTION LABEL  (.section-label)
 *
 * A small uppercase heading over a group of fields or rows ("DOCUMENTOS",
 * "ETAPAS"). The one place uppercase + letter-spacing is used. Keep it short.
 * ---------------------------------------------------------------------------*/
.section-label
{
    margin: 4px 2px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
}


/* -----------------------------------------------------------------------------
 * INFO DOT  (.info-dot)  +  INFO POPUP  (.info-popup)
 *
 * A small circled "i" you put next to a label or a control to explain it. Tap
 * it and a little popup opens with the text; tap it again, tap anywhere else,
 * press Esc or scroll and it closes. It is a POPUP, not a dialog - it has no
 * "x", no backdrop, and never blocks the page.
 *
 *     <label for="tz">Zona horaria
 *       <button class="info-dot" data-info="Las horas se guardan en UTC y se
 *       muestran en tu zona."></button>
 *     </label>
 *
 * shared/ui.js fills in the icon + ARIA and wires the open/close (it runs on
 * load and watches for dots added later; call NayiveUI.applyInfoDots(root) after
 * building markup by hand). The text comes from `data-info`; "\n" starts a new
 * line. Keep it to a sentence or two - anything longer belongs in a dialog.
 *
 * COLOUR: --link (info-blue) for both the dot and the popup's border, so it
 * stays legible at 16px in both schemes and never reads as the green --accent
 * (reserved for active / primary). The dot goes --accent only on hover / while
 * its popup is open.
 * ---------------------------------------------------------------------------*/
.info-dot
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    padding: 0;
    margin: 0 0 0 4px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--link);        /* info-blue - readable at 16px, not the green accent */
    vertical-align: middle;
    cursor: pointer;
    transition: color var(--tr-fast);
}
.info-dot svg           { width: 15px; height: 15px; display: block; }
.info-dot:hover,
.info-dot.is-open       { color: var(--accent); }
.info-dot:focus         { outline: none; }
.info-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.info-popup
{
    position: absolute;
    z-index: 200;                /* above sheets (100), below nothing else */
    max-width: 260px;
    padding: 10px 12px;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--link);   /* info-blue, ties the popup to its dot */
    border-radius: var(--radius-m);
    box-shadow: var(--elev-dialog);
    white-space: pre-wrap;       /* honour "\n" in data-info */
}


/* -----------------------------------------------------------------------------
 * SYNC INDICATOR + TOAST  - defined in theme.css
 *
 * .sync-indicator  a filled-circle SVG in the header. Toggle the state class:
 *     (none)     --danger red   not synced yet (the safe start state)
 *     .synced    --ok green     saved
 *     .busy      --busy blue    a GET / PUT is in flight
 *     .offline   --warn gold    working offline, changes queued
 *
 * .toast  a bottom-centre transient message. Put <div id="toast" class="toast">
 * in the page and call NayiveUI.toast("Guardado"). For confirmations only, not
 * for errors that need the user to act.
 * ---------------------------------------------------------------------------*/


/* -----------------------------------------------------------------------------
 * (Removed) TOOLTIP PEEK + FIRST-VISIT HELP NUDGE
 *
 * The old touch-only long-press "peek" overlay and the ~9 s idle "nudge" card
 * were dropped for being too intrusive. The one-time first-run intro card
 * (.intro-*, below) stays, and the "?" dot next to each app title re-opens it.
 * ---------------------------------------------------------------------------*/

/* A long-press on a button would otherwise pop the iOS callout / selection menu. */
button { -webkit-touch-callout: none; }


/* -----------------------------------------------------------------------------
 * HELP DIALOG  (.intro-*)
 *
 * Opened by the "?" button at the end of an app's toolbar (a normal toolbar
 * button carrying [data-intro-open]) - never on its own. Built on the shared
 * .sheet by shared/ui.js (NayiveUI.firstRun / .showIntro): app name, an optional
 * one-line summary, then one row per toolbar button (its glyph + name + a short
 * explanation). The launcher's copy adds the "volver a las apps" tip and a
 * "No volver a mostrar" button, and re-opens every visit until that is clicked.
 * Closes on its corner × / Escape only, like any Nayive dialog.
 * ---------------------------------------------------------------------------*/
.intro-btns
{
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}
.intro-btns li
{
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 2px;
    font-size: 0.86rem;
    line-height: 1.35;
}
.intro-btns li + li  { border-top: 1px solid var(--line); }

.intro-btn-i
{
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 0.8rem;
}
.intro-btn-i svg     { width: 18px; height: 18px; display: block; }

.intro-btn-t         { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.intro-btn-t b       { font-weight: 600; color: var(--text); }
.intro-btn-t span    { color: var(--text-dim); }

/* Close (x), top-right corner like every Nayive dialog. Floated so the title
   flows beside it; sticky so it stays in the corner while a long list scrolls
   under it (hence the --card backdrop). */
.intro-close
{
    position: sticky;
    top: 0;
    float: right;
    margin: -2px -4px 2px 10px;
    background: var(--card);
    border-radius: 50%;
    box-shadow: 0 0 0 5px var(--card);   /* widen the mask over scrolling rows */
    z-index: 2;
}

/* Launcher only: the "tap the app name / icon to go back" tip under the list. */
.intro-home-hint
{
    margin-top: 14px;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--text-dim);
}

/* Launcher only: the wide "No volver a mostrar" button, alone in the bottom row. */
.intro-dismiss
{
    flex: 1 1 auto;
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--card2);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: color var(--tr-fast), background var(--tr-fast);
}
.intro-dismiss:hover { color: var(--text); background: color-mix(in srgb, var(--accent) 12%, var(--card2)); }


/* ---------------------------------------------------------------------------
 * INSTALL-AS-APP DIALOG  (.install-*)
 *
 * Built by NayiveUI.offerInstall() on the shared .sheet, reusing the help
 * dialog's row list (.intro-btns) for the three "what you get" lines and its
 * wide button (.intro-dismiss) for the actions. Only the app logo, the numbered
 * iOS steps and the filled primary button are new.
 * ---------------------------------------------------------------------------*/
/* The corner x is pinned instead of floated here: floating it steals width from
   the first line and pushes the centred logo off-centre. */
.install-sheet .intro-close
{
    position: absolute;
    top: 12px;
    right: 12px;
    float: none;
    margin: 0;
    box-shadow: none;
}
.install-logo
{
    display: block;
    width: 64px;
    height: 64px;
    margin: 2px auto 10px;
    border-radius: 16px;
    box-shadow: var(--elev-card);
}
.install-title { text-align: center; }
.install-lead  { text-align: center; }

.install-h     { margin-top: 16px; }

/* The three iOS steps: a counter bubble, the real glyph, then the sentence. */
.install-steps
{
    counter-reset: install-step;
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
}
.install-steps li
{
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px 2px;
    font-size: 0.86rem;
    line-height: 1.35;
}
.install-steps li + li { border-top: 1px solid var(--line); }
.install-steps li::before
{
    counter-increment: install-step;
    content: counter(install-step);
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--card2);
    color: var(--text-dim);
    font-size: 0.78rem;
    font-weight: 600;
}
.install-steps b { font-weight: 600; color: var(--text); }

.install-note
{
    margin-top: 14px;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-dim);
}

/* Stacked full-width actions: Instalar / Ahora no / No mostrar más. */
.install-actions
{
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}
.intro-dismiss.primary
{
    border-color: transparent;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.95rem;
    font-weight: 600;
}
.intro-dismiss.primary:hover { background: var(--accent); color: var(--on-accent); filter: brightness(1.06); }
.install-never { border-color: transparent; background: none; font-size: 0.8rem; min-height: 36px; }
.install-never:hover { background: none; color: var(--text); text-decoration: underline; }
