/* Field Story Builder X — ToolKit & Subtool Runner Styles (10.5g) */

body.toolkit-active {
    padding-top: env(safe-area-inset-top, 0px) !important;
}

body.toolkit-active #app-header,
body.toolkit-active .bottom-nav {
    display: none;
}

body.toolkit-active #view-toolkit {
    padding-top: 8px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    max-width: 720px;
}

/* Compact Two-Option Choice Popup */
.tk-choice-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: flex-start;
    justify-content: flex-end;
    padding: calc(74px + env(safe-area-inset-top, 0px)) 14px 14px 14px;
    background: rgba(5, 8, 14, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.tk-choice-overlay.is-open {
    display: flex;
}

.tk-choice-popover {
    width: min(240px, calc(100vw - 28px));
    padding: 10px;
    border-radius: var(--radius-lg);
    background: rgba(13, 18, 28, 0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-strong);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.78), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tk-choice-btn {
    width: 100%;
    padding: 13px 14px;
    border-radius: var(--radius-md);
    background: rgba(22, 30, 43, 0.9);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}

.tk-choice-btn.is-dev {
    border-left: 4px solid var(--amber);
    color: var(--amber);
}

.tk-choice-btn.is-toolkit {
    border-left: 4px solid var(--cyan);
    color: var(--cyan);
}

.tk-choice-btn:hover {
    border-color: var(--accent);
    background: rgba(30, 41, 59, 0.98);
}

.tk-choice-btn:active {
    transform: scale(0.97);
}

/* ToolKit Landing Window */
.tk-page {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.tk-banner-row {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.tk-logo-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 86px;
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    background: rgba(13, 18, 28, 0.78);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-strong);
    border-left: 4px solid var(--accent);
    color: var(--text-main);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.tk-logo-banner:hover {
    border-color: var(--cyan);
    border-left-color: var(--accent);
    background: rgba(22, 30, 43, 0.9);
}

.tk-logo-banner:active {
    transform: scale(0.99);
}

.tk-banner-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.tk-banner-label {
    font-size: var(--fs-xl);
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    line-height: 1.1;
}

.tk-banner-desc {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.3;
}

/* ToolKit Reticle Star */
.tk-reticle-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--cyan);
    filter: drop-shadow(0 0 8px rgba(6, 182, 212, 0.55));
}

.tk-reticle-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1), color 0.2s ease;
}

.tk-reticle-core {
    position: relative;
    width: 28px;
    height: 28px;
    color: var(--accent);
    transition: transform 0.2s ease, color 0.2s ease;
}

.tk-reticle-wrap.is-locked {
    color: var(--accent);
    filter: drop-shadow(0 0 12px rgba(245, 158, 11, 0.8));
}

.tk-reticle-wrap.is-locked .tk-reticle-core {
    color: var(--cyan);
    transform: scale(1.16);
}

/* Two-Column Tool Grid */
.tk-two-col-grid {
    display: grid;
    /* v11i: minmax(0,1fr) lets the columns shrink below their min-content
       width so the 2-col grid never overflows the container on phones (the
       old repeat(2,1fr) pushed the right column off-screen because the
       icon-well + nowrap description forced a min width). */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
}

.tk-grid-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    min-height: 78px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: rgba(14, 21, 33, 0.78);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(120, 145, 180, 0.18);
    border-left: 4px solid var(--tk-accent, #22d3ee);
    color: var(--text-main);
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: 800;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.tk-grid-btn:hover {
    border-color: var(--tk-accent, var(--accent));
    border-left-color: var(--tk-accent, var(--accent));
    background: rgba(22, 30, 43, 0.92);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45), 0 0 14px color-mix(in srgb, var(--tk-accent, #22d3ee) 28%, transparent);
}

.tk-grid-btn:active {
    transform: scale(0.97);
}

.tk-grid-btn.is-soon {
    opacity: 0.78;
}

/* v11i: ToolKit-3 glass-pane card internals. Icon in a tinted well on the
   left, name + description stacked on the right — the ToolKit-3 visual
   language the user asked for (glass panes, icons, descriptions, title). */
.tk-grid-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    line-height: 1;
    border-radius: 10px;
    background: color-mix(in srgb, var(--tk-accent, #22d3ee) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--tk-accent, #22d3ee) 32%, transparent);
}

.tk-grid-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.tk-grid-name {
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.15;
    color: var(--text-main);
}

.tk-grid-desc {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.3;
    color: var(--text-muted);
    /* v11i: allow the description to wrap (was nowrap, which forced the
       2-col grid to overflow on phones). Cap at 2 lines with ellipsis so
       long descriptions stay tidy. */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

/* v11i: top return link — glassy pill, sits above the banner so the user
   can jump back to the main app from the top OR the bottom. */
.tk-top-return {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    margin-bottom: 2px;
}

.tk-link-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: var(--radius-md);
    background: rgba(13, 18, 28, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.tk-link-back:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    background: rgba(22, 30, 43, 0.92);
}

.tk-link-back-arrow {
    font-size: 0.9rem;
    line-height: 1;
}

.tk-bottom-return {
    margin-top: 4px;
    width: 100%;
}

.tk-return-builder-btn {
    background: linear-gradient(135deg, var(--accent) 0%, var(--orange) 100%);
    color: #0a0e14;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.25);
}

.tk-coming-soon-msg {
    padding: 8px 4px;
    font-size: var(--fs-md);
    font-weight: 800;
    color: var(--accent);
    text-align: center;
}

/* Fullscreen Subtool Runner */
.tk-subtool-runner {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: none;
    flex-direction: column;
    background: var(--bg-primary);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tk-subtool-runner.is-open {
    display: flex;
}

.tk-subtool-topbar {
    position: fixed;
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: 10px;
    z-index: 10002;
    pointer-events: none;
}

.tk-subtool-badge {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: var(--radius-md);
    background: rgba(10, 14, 20, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--cyan);
    color: var(--cyan);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.tk-subtool-frame {
    width: 100%;
    height: 100%;
    border: none;
    flex: 1;
    background: var(--bg-primary);
}

