* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: #111;
    color: #eee;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

header {
    position: sticky;
    top: 0;
    background: #000;
    border-bottom: 1px solid #2a2a2a;
    padding: env(safe-area-inset-top, 0.75rem) 1rem 0;
    z-index: 10;
}

header h1 {
    margin: 0.75rem 0 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #fff;
}

/* Section segmented control --------------------------------------------- */

.sections {
    display: flex;
    gap: 0.25rem;
    background: #181818;
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 0.5rem;
}

.section {
    flex: 1;
    background: transparent;
    color: #aaa;
    border: 0;
    border-radius: 8px;
    padding: 0.55rem 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.section.active {
    background: #2a2a2a;
    color: #fff;
}

.section.disabled {
    color: #444;
    cursor: default;
}

/* Tabs ------------------------------------------------------------------ */

.tabs {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    background: transparent;
    color: #888;
    border: 0;
    border-bottom: 3px solid transparent;
    padding: 0.65rem 0.9rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.tab.active {
    color: #fff;
    border-bottom-color: #f5a623;
}

/* Grid + pad buttons ---------------------------------------------------- */

main {
    padding: 1rem;
    padding-bottom: calc(env(safe-area-inset-bottom, 1rem) + 1rem);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.pad {
    position: relative;
    background: #1c1c1c;
    color: #fff;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 0.9rem 0.9rem 0.75rem;
    min-height: 92px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    transition: background 0.1s, transform 0.05s, border-color 0.15s;
}

.pad:active {
    background: #f5a623;
    color: #000;
    transform: scale(0.97);
}

.pad .pad-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.pad .pad-sub {
    font-size: 0.78rem;
    color: #888;
    line-height: 1.2;
}

.pad:active .pad-sub { color: #333; }

.pad .pad-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #2a2a2a;
    color: #f5a623;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Style-specific pad accents (subtle, left border) */
.pad.style-hazard { border-left: 4px solid #ffd400; }
.pad.style-warning { border-left: 4px solid #f5a623; }
.pad.style-crosshair { border-left: 4px solid #4aa3ff; }
.pad.style-arrow-right { border-left: 4px solid #6ad17d; }
.pad.style-form { border-left: 4px solid #c183f5; }
.pad.style-stamp { border-left: 4px solid #666; }

.empty {
    grid-column: 1 / -1;
    color: #666;
    text-align: center;
    padding: 2rem 0;
}

/* Status toast ---------------------------------------------------------- */

.status {
    position: fixed;
    left: 50%;
    bottom: calc(env(safe-area-inset-bottom, 1rem) + 1rem);
    transform: translateX(-50%);
    background: #1c1c1c;
    border: 1px solid #333;
    border-radius: 999px;
    padding: 0.6rem 1.25rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    font-size: 0.9rem;
    min-width: 180px;
    text-align: center;
    z-index: 20;
}

.status.success { border-color: #4caf50; color: #a5d6a7; }
.status.error { border-color: #f44336; color: #ef9a9a; }

/* Dialogs --------------------------------------------------------------- */

dialog {
    background: #1c1c1c;
    color: #eee;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 1.5rem;
    min-width: 300px;
    max-width: 90vw;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.75); }

dialog h2 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

dialog p {
    margin: 0 0 0.75rem;
    color: #aaa;
    font-size: 0.85rem;
}

/* Generic dialog input (used by the token dialog) */
dialog input {
    width: 100%;
    background: #111;
    color: #eee;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 0.6rem;
    font-family: "SF Mono", Menlo, monospace;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Prompt dialog field rows */
#prompt-fields .field {
    display: block;
    margin-bottom: 0.9rem;
}

#prompt-fields .field span {
    display: block;
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 0.3rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

#prompt-fields .field input {
    margin-bottom: 0;
    font-family: inherit;
    font-size: 1rem;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

dialog button {
    border: 0;
    border-radius: 6px;
    padding: 0.55rem 1.25rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
}

.btn-primary {
    background: #f5a623;
    color: #000;
}

.btn-secondary {
    background: transparent;
    color: #aaa;
    border: 1px solid #333;
}
