/* Scanfas app shell: home, new design, files, settings. Native iOS feel: the system font,
   grouped lists, large titles, a tab bar; light and dark. */

:root {
    --bg: #f2f2f7;
    --card: #ffffff;
    --fill: #e4e4ea;
    --label: #111114;
    --secondary: #6c6c72;
    --separator: #e3e3e8;
    --accent: #3f5bd9;
    --accent-soft: #eef1fd;
    --ink: #0b0c14;
    --ink-text: #ffffff;
    --ink-muted: #b4b6c2;
    --ink-chip: #1e2131;
    --hero-accent: #a9b6ee;
    --danger: #d70015;
    --tabbar: rgba(249, 249, 251, 0.92);
    --radius: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: var(--label);
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --card: #1c1c1e;
        --fill: #2c2c2e;
        --label: #f5f5f7;
        --secondary: #a1a1a6;
        --separator: #38383a;
        --accent: #7d93f2;
        --accent-soft: #1f2440;
        --ink: #1c1c1e;
        --ink-chip: #2c2c2e;
        --danger: #ff453a;
        --tabbar: rgba(22, 22, 24, 0.92);
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); }
body {
    min-height: 100vh;
    padding: env(safe-area-inset-top) 0 calc(84px + env(safe-area-inset-bottom));
    letter-spacing: -0.01em;
}
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.screen { max-width: 640px; margin: 0 auto; padding: 18px 16px 24px; display: flex; flex-direction: column; gap: 20px; }

/* ------------------------------------------------------------ headers */

.brand { display: flex; align-items: center; gap: 12px; padding: 8px 4px 0; }
.brand h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.brand p { margin: 2px 0 0; font-size: 13px; font-weight: 500; color: var(--secondary); }
.large-title { padding: 8px 4px 0; }
.large-title h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }
.navbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px; }
.navbar h1 { margin: 0; font-size: 17px; font-weight: 600; }
.nav-text { font-size: 17px; }
.navbar > :last-child { justify-self: end; }
.caps { margin: 4px 16px -12px; font-size: 13px; font-weight: 400; color: var(--secondary); text-transform: uppercase; letter-spacing: 0.04em; }

/* ------------------------------------------------------------ home */

.hero {
    position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 6px;
    background: var(--ink); color: var(--ink-text); border-radius: 26px; padding: 22px;
}
.hero::before { content: ""; position: absolute; right: -36px; top: -40px; width: 150px; height: 150px; border-radius: 50%; background: #1a1f3a; }
.hero > * { position: relative; }
.hero-page {
    position: absolute; right: 28px; top: 26px; width: 58px; height: 80px; transform: rotate(8deg);
    background: #f4f5fa; border-radius: 4px; padding: 9px 8px; display: flex; flex-direction: column; gap: 4px;
}
.hero-page span { height: 3px; background: #c7cbe0; border-radius: 2px; }
.hero-page span:first-child { height: 12px; width: 70%; background: #3f5bd9; }
.hero-page span:last-child { height: 18px; margin-top: 4px; background: #a9b6ee; border-radius: 9px; }
.eyebrow { font-size: 13px; color: var(--hero-accent); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.hero strong { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.12; max-width: 230px; }
.hero-text { font-size: 14px; color: var(--ink-muted); line-height: 1.4; max-width: 230px; }
.hero-row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips span { font-size: 12px; color: #d8dcf0; background: var(--ink-chip); padding: 6px 10px; border-radius: 999px; }
.hero-button { flex: none; width: 56px; height: 56px; border-radius: 28px; background: #ffffff; color: #0b0c14; display: flex; align-items: center; justify-content: center; }
.hero-button svg { stroke-width: 2.4; }

.section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; }
.section-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.section-head a { font-size: 15px; font-weight: 500; }

.template-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.template-row::-webkit-scrollbar { display: none; }

.duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--card); color: var(--label); border-radius: 18px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; min-height: 60px; }
.tile strong { display: block; font-size: 16px; font-weight: 600; }
.tile small { display: block; font-size: 12px; color: var(--secondary); }
.tile-icon { flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.tile-icon svg { width: 19px; height: 19px; stroke-width: 2; }

/* ------------------------------------------------------------ grouped lists */

.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.list > * + * { border-top: 1px solid var(--separator); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; min-height: 48px; font-size: 16px; }
.row .value { color: var(--secondary); text-align: right; font-size: 15px; }
.row .value .ok { color: #1e8e3e; font-weight: 600; }
.button-row { width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; color: var(--accent); }
.chev { width: 8px; height: 14px; stroke: #b5b5bb; stroke-width: 2; flex: none; }
details.row { display: block; }
details summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
details summary::after { content: "›"; color: #b5b5bb; font-size: 22px; line-height: 1; transition: transform .15s; }
details[open] summary::after { transform: rotate(90deg); }
details ol { margin: 10px 0 2px; padding-left: 20px; color: var(--secondary); font-size: 15px; line-height: 1.5; }
.footnote { margin: -8px 16px 0; font-size: 13px; color: var(--secondary); line-height: 1.45; }
.footnote:empty { display: none; }
.empty { margin: 0; padding: 16px; color: var(--secondary); font-size: 15px; }

/* A saved design in a list */
.doc-row { display: flex; align-items: center; gap: 14px; padding: 10px 16px; color: var(--label); }
.doc-row .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-row .info strong { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-row .info small { font-size: 13px; color: var(--secondary); }

/* A page preview: the design's page shape and background */
.page-thumb {
    flex: none; display: flex; flex-direction: column; gap: 3px; padding: 7px 6px; border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 4px 10px rgba(17, 17, 20, 0.08); overflow: hidden;
}
.page-thumb i { display: block; height: 2px; border-radius: 2px; background: currentColor; opacity: 0.25; }
.page-thumb i:first-child { height: 4px; width: 60%; opacity: 0.6; }

/* ------------------------------------------------------------ new design */

.sizes { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; }
.sizes::-webkit-scrollbar { display: none; }
.size {
    flex: none; width: 92px; padding: 12px 8px; border: 0; border-radius: 16px; background: var(--card); color: var(--label);
    display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer;
}
.size .shape { height: 44px; display: flex; align-items: center; justify-content: center; }
.size .shape span { border: 1.8px solid currentColor; border-radius: 3px; }
.size strong { font-size: 13px; font-weight: 600; }
.size small { font-size: 11px; opacity: 0.7; }
.size[aria-checked="true"] { background: var(--accent); color: #ffffff; }
.custom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--card); border-radius: 16px; padding: 12px 14px; }
.custom label { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--secondary); }
.custom input, .custom select { width: 84px; padding: 8px 10px; border-radius: 10px; border: 0; background: var(--fill); }
.custom select { width: auto; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.template {
    height: 150px; border-radius: 14px; background: var(--card); display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 8px; color: var(--label); font-size: 12px; font-weight: 500; text-align: center; padding: 8px;
}
.template img { max-width: 100%; max-height: 104px; border-radius: 3px; box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 6px 14px rgba(17,17,20,.12); }
.template-row .template { flex: none; width: 104px; height: 140px; }
.bottom-action { position: sticky; bottom: calc(96px + env(safe-area-inset-bottom)); margin-top: 8px; }
.primary-button {
    display: flex; align-items: center; justify-content: center; height: 54px; border-radius: 16px;
    background: var(--accent); color: #ffffff; font-size: 17px; font-weight: 600;
}

/* ------------------------------------------------------------ files */

.search { display: flex; align-items: center; gap: 8px; background: var(--fill); border-radius: 12px; padding: 9px 12px; color: var(--secondary); margin-top: -6px; }
.search svg { width: 16px; height: 16px; stroke-width: 2.2; }
.search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 16px; color: var(--label); padding: 0; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.file { position: relative; display: flex; flex-direction: column; gap: 8px; color: var(--label); }
.file .card { height: 180px; border-radius: 16px; background: var(--card); display: flex; align-items: center; justify-content: center; }
.file .meta { padding: 0 4px; display: flex; flex-direction: column; gap: 1px; padding-right: 32px; }
.file .meta strong { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file .meta small { font-size: 12px; color: var(--secondary); }
.file .more {
    position: absolute; right: 0; bottom: 4px; width: 32px; height: 32px; border: 0; border-radius: 16px;
    background: transparent; color: var(--secondary); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.fab {
    position: fixed; right: max(20px, calc(50% - 300px)); bottom: calc(104px + env(safe-area-inset-bottom));
    width: 58px; height: 58px; border-radius: 29px; background: var(--ink); color: #ffffff;
    display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 22px rgba(11, 12, 20, 0.35);
}
.fab svg { stroke-width: 2.4; }

dialog#file-menu {
    border: 0; padding: 0; background: transparent; width: min(560px, calc(100vw - 16px)); margin: auto auto 8px;
}
dialog#file-menu::backdrop { background: rgba(0, 0, 0, 0.32); }
dialog#file-menu form { display: flex; flex-direction: column; gap: 8px; }
dialog#file-menu p { margin: 0; padding: 12px; text-align: center; font-size: 13px; color: var(--secondary); background: var(--card); border-radius: 14px 14px 0 0; margin-bottom: -8px; border-bottom: 1px solid var(--separator); }
dialog#file-menu button { height: 56px; border: 0; background: var(--card); color: var(--accent); font-size: 20px; cursor: pointer; }
dialog#file-menu button[value="open"] { border-radius: 0 0 14px 14px; margin-top: 0; }
dialog#file-menu button.danger { color: var(--danger); border-radius: 14px; }
dialog#file-menu button.cancel { border-radius: 14px; font-weight: 600; }

/* ------------------------------------------------------------ tab bar */

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 7px max(8px, calc(50% - 320px)) calc(8px + env(safe-area-inset-bottom));
    background: var(--tabbar); border-top: 1px solid var(--separator);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--secondary); font-size: 10.5px; font-weight: 500; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabbar a[aria-current="page"] svg { fill: currentColor; fill-opacity: 0.18; }
.sheet-screen ~ .tabbar { display: grid; }

#install { display: contents; }
@media (prefers-color-scheme: dark) {
    .fab { background: var(--accent); }
    .hero::before { background: #262b48; }
}
