/*
 * GPT theme: AI Tools module (catalog and tool workspace). Written for this theme.
 * The page frame and sidebar come from shell.css.
 */

:root {
    color-scheme: dark;
    --gt-bg: #000000;
    --gt-surface: #1b1b1b;
    --gt-surface-2: #242424;
    --gt-hover: #1a1a1a;
    --gt-text: #f3f3f3;
    --gt-text-2: #afafaf;
    --gt-text-3: #8f8f8f;
    --gt-line: #2a2a2a;
    --gt-outline: #424242;
    --gt-solid: #ffffff;
    --gt-on-solid: #0d0d0d;
    --gt-accent: #3a83f7;
    --gt-popover: #2c2c2c;
    --gt-danger: #ff6b66;
    --gt-danger-bg: rgba(224, 46, 42, .12);
    --gt-ok: #5fd39a;
}

[data-theme-version="light"] {
    color-scheme: light;
    --gt-bg: #ffffff;
    --gt-surface: #f4f4f4;
    --gt-surface-2: #ececec;
    --gt-hover: #f4f4f4;
    --gt-text: #0d0d0d;
    --gt-text-2: #5d5d5d;
    --gt-text-3: #8f8f8f;
    --gt-line: #e5e5e5;
    --gt-outline: #d9d9d9;
    --gt-solid: #0d0d0d;
    --gt-on-solid: #ffffff;
    --gt-accent: #2964aa;
    --gt-popover: #ffffff;
    --gt-danger: #c62320;
    --gt-danger-bg: rgba(224, 46, 42, .08);
    --gt-ok: #1e7f52;
}

* {
    box-sizing: border-box;
}

body.gpt-tools {
    margin: 0;
    background: var(--gt-bg);
    color: var(--gt-text);
    font-family: "Inter", ui-sans-serif, -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 20px;
    -webkit-font-smoothing: antialiased;
}

body.gpt-tools button,
body.gpt-tools input,
body.gpt-tools select,
body.gpt-tools textarea {
    font: inherit;
    color: inherit;
}

.gt-main a {
    color: inherit;
    text-decoration: none;
}

.gt-main .material-symbols-outlined {
    font-size: 20px;
}

/* ---------- Catalog ---------- */

.gt-catalog {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 56px 20px 80px;
}

.gt-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.gt-hero h1 {
    margin: 0 0 10px;
    font-size: 36px;
    font-weight: 600;
    line-height: 44px;
    letter-spacing: -.02em;
}

.gt-hero p {
    max-width: 620px;
    margin: 0 0 28px;
    color: var(--gt-text-2);
    font-size: 15px;
    line-height: 24px;
}

.gt-search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 620px;
    height: 52px;
    padding: 0 18px;
    border-radius: 26px;
    background: var(--gt-surface);
    color: var(--gt-text-2);
}

.gt-search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--gt-text);
    font-size: 16px;
}

.gt-search input::placeholder {
    color: var(--gt-text-2);
}

.gt-quota {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 7px 14px;
    border: 1px solid var(--gt-line);
    border-radius: 999px;
    color: var(--gt-text-2);
    font-size: 13px;
}

.gt-quota strong {
    color: var(--gt-text);
    font-weight: 600;
}

.gt-quota .material-symbols-outlined {
    font-size: 18px;
}

.gt-quota.is-blocked {
    border-color: transparent;
    background: var(--gt-danger-bg);
    color: var(--gt-danger);
}

.gt-quota.is-blocked strong {
    color: inherit;
}

.gt-quota a {
    margin-left: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--gt-solid);
    color: var(--gt-on-solid);
    font-weight: 500;
}

.gt-tabs {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    gap: 6px;
    margin: 36px -20px 0;
    padding: 10px 20px;
    overflow-x: auto;
    border-bottom: 1px solid var(--gt-line);
    background: var(--gt-bg);
    scrollbar-width: none;
}

.gt-tabs::-webkit-scrollbar {
    display: none;
}

.gt-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--gt-text-2);
    cursor: pointer;
}

.gt-tab:hover {
    background: var(--gt-hover);
    color: var(--gt-text);
}

.gt-tab.active {
    background: var(--gt-surface-2);
    color: var(--gt-text);
    font-weight: 500;
}

.gt-tab small {
    color: var(--gt-text-3);
    font-size: 12px;
}

.gt-section {
    margin-top: 40px;
}

.gt-section[hidden] {
    display: none;
}

.gt-section-head {
    margin-bottom: 14px;
}

.gt-section-head h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
}

.gt-section-head p {
    margin: 2px 0 0;
    color: var(--gt-text-2);
}

.gt-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 16px;
}

.gt-main a.tool-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    padding: 12px;
    border-radius: 14px;
}

.gt-main a.tool-card:hover {
    background: var(--gt-hover);
}

.tool-card[hidden] {
    display: none !important;
}

.gt-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--gt-surface);
    color: var(--gt-text);
    font-size: 18px;
}

.gt-card-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.gt-card-text strong {
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    line-height: 22px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gt-card-text span {
    display: -webkit-box;
    overflow: hidden;
    color: var(--gt-text-2);
    font-size: 13px;
    line-height: 18px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.gt-go {
    flex-shrink: 0;
    color: var(--gt-text-3);
    opacity: 0;
}

.tool-card:hover .gt-go {
    opacity: 1;
}

.gt-none {
    margin-top: 48px;
    color: var(--gt-text-2);
    text-align: center;
}

.gt-none[hidden] {
    display: none;
}

/* ---------- Tool workspace ---------- */

.gt-work {
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    min-height: 100vh;
}

.gt-form {
    display: flex;
    flex-direction: column;
    max-height: 100vh;
    border-right: 1px solid var(--gt-line);
    position: sticky;
    top: 0;
}

.gt-form-head {
    padding: 20px 24px 16px;
}

.gt-crumb,
.gt-main a.gt-crumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 18px;
    color: var(--gt-text-2);
    font-size: 13px;
}

.gt-main a.gt-crumb:hover {
    color: var(--gt-text);
}

.gt-crumb .material-symbols-outlined {
    font-size: 18px;
}

.gt-tool {
    display: flex;
    align-items: center;
    gap: 14px;
}

.gt-tool h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    line-height: 26px;
}

.gt-tool small {
    color: var(--gt-text-2);
    font-size: 13px;
}

.gt-tool-desc {
    margin: 14px 0 0;
    color: var(--gt-text-2);
    line-height: 22px;
}

.locked {
    margin: 0 24px 8px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--gt-danger-bg);
}

.locked h3 {
    margin: 0 0 4px;
    color: var(--gt-danger);
    font-size: 14px;
    font-weight: 600;
}

.locked p {
    margin: 0;
    color: var(--gt-text-2);
    font-size: 13px;
}

.gt-main .locked a {
    display: inline-flex;
    margin-top: 10px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--gt-solid);
    color: var(--gt-on-solid);
    font-size: 13px;
    font-weight: 500;
}

.gt-fields {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    padding: 8px 24px 20px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gt-outline) transparent;
}

.gt-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.gt-field > label,
.gt-field > span {
    color: var(--gt-text-2);
    font-size: 13px;
    font-weight: 500;
}

.gt-field input,
.gt-field select,
.gt-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gt-line);
    border-radius: 12px;
    outline: none;
    background: var(--gt-surface);
    color: var(--gt-text);
    font-size: 15px;
    line-height: 22px;
    transition: border-color .15s ease;
}

.gt-field input,
.gt-field select {
    height: 44px;
}

.gt-field textarea {
    min-height: 104px;
    resize: vertical;
}

.gt-field input:focus,
.gt-field select:focus,
.gt-field textarea:focus {
    border-color: var(--gt-outline);
}

.gt-field ::placeholder {
    color: var(--gt-text-3);
}

.gt-field select option {
    background: var(--gt-popover);
    color: var(--gt-text);
}

.gt-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.gt-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid var(--gt-line);
    border-radius: 12px;
}

.gt-toggle strong {
    display: block;
    font-weight: 500;
}

.gt-toggle small {
    color: var(--gt-text-2);
    font-size: 13px;
}

.gt-switch {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 24px;
    cursor: pointer;
}

.gt-switch input {
    position: absolute;
    opacity: 0;
}

.gt-switch span {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--gt-outline);
    transition: background .15s ease;
}

.gt-switch span::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform .15s ease;
}

.gt-switch input:checked + span {
    background: var(--gt-accent);
}

.gt-switch input:checked + span::after {
    transform: translateX(16px);
}

.gt-switch input:disabled + span {
    opacity: .45;
    cursor: not-allowed;
}

.gt-form-foot {
    padding: 14px 24px 20px;
    border-top: 1px solid var(--gt-line);
}

.gt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--gt-outline);
    border-radius: 999px;
    background: transparent;
    color: var(--gt-text);
    cursor: pointer;
}

.gt-btn:hover {
    background: var(--gt-hover);
}

.gt-btn-primary {
    width: 100%;
    height: 48px;
    border-color: var(--gt-solid);
    background: var(--gt-solid);
    color: var(--gt-on-solid) !important;
    font-size: 15px;
    font-weight: 500;
}

.gt-btn-primary:hover {
    background: var(--gt-solid);
    opacity: .88;
}

.gt-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.status-line {
    min-height: 18px;
    margin-top: 10px;
    color: var(--gt-text-2);
    font-size: 13px;
    text-align: center;
}

.status-line strong {
    color: var(--gt-text);
}

.status-line .success {
    color: var(--gt-ok);
}

.status-line .error {
    color: var(--gt-danger);
}

.gt-result {
    min-width: 0;
    padding: 20px 32px 64px;
}

.gt-result-bar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 760px;
    margin: 0 auto;
    padding: 6px 0 14px;
    background: var(--gt-bg);
}

.gt-result-bar h2 {
    margin: 0;
    color: var(--gt-text-2);
    font-size: 14px;
    font-weight: 500;
}

#writer-output {
    max-width: 760px;
    margin: 0 auto;
}

.output-placeholder,
.output-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46vh;
    padding: 32px;
    border: 1px dashed var(--gt-line);
    border-radius: 20px;
    color: var(--gt-text-2);
    font-size: 15px;
    line-height: 24px;
    text-align: center;
}

.output-placeholder > div {
    max-width: 340px;
}

.output-placeholder .material-symbols-outlined {
    display: block;
    margin: 0 auto 12px;
    color: var(--gt-text-3);
    font-size: 32px;
}

.output-loading-copy {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--gt-text);
}

.output-loading-dots {
    display: inline-flex;
    gap: 5px;
}

.output-loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gt-text-2);
    animation: gt-dot 1.1s ease-in-out infinite;
}

.output-loading-dots span:nth-child(2) {
    animation-delay: .18s;
}

.output-loading-dots span:nth-child(3) {
    animation-delay: .36s;
}

@keyframes gt-dot {
    0%, 80%, 100% { opacity: .25; transform: scale(.85); }
    40% { opacity: 1; transform: scale(1); }
}

/* Generated document */
.output-rendered {
    font-size: 16px;
    line-height: 28px;
    overflow-wrap: anywhere;
}

.output-rendered > :first-child {
    margin-top: 0;
}

.output-rendered > :last-child {
    margin-bottom: 0;
}

.output-rendered p {
    margin: 0 0 18px;
}

.output-rendered h1,
.output-rendered h2,
.output-rendered h3,
.output-rendered h4 {
    margin: 32px 0 12px;
    font-weight: 600;
    letter-spacing: -.01em;
}

.output-rendered h1 {
    font-size: 30px;
    line-height: 38px;
}

.output-rendered h2 {
    font-size: 22px;
    line-height: 30px;
}

.output-rendered h3 {
    font-size: 18px;
    line-height: 26px;
}

.output-rendered ul,
.output-rendered ol {
    margin: 0 0 18px;
    padding-left: 24px;
}

.output-rendered li {
    margin-bottom: 6px;
}

.output-rendered strong {
    font-weight: 600;
}

.output-rendered a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.output-rendered hr {
    height: 1px;
    margin: 28px 0;
    border: 0;
    background: var(--gt-outline);
}

.output-rendered :not(pre) > code {
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--gt-surface-2);
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 14px;
}

.output-rendered pre {
    margin: 0 0 18px;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--gt-surface-2);
    overflow-x: auto;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 14px;
    line-height: 22px;
}

.output-rendered table {
    display: block;
    width: 100%;
    margin: 0 0 18px;
    border-collapse: collapse;
    overflow-x: auto;
    font-size: 15px;
    line-height: 24px;
}

.output-rendered th,
.output-rendered td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--gt-outline);
    text-align: left;
    vertical-align: top;
}

.output-rendered th {
    font-weight: 600;
}

.output-rendered blockquote {
    margin: 0 0 18px;
    padding: 4px 0 4px 16px;
    border-left: 3px solid var(--gt-outline);
    color: var(--gt-text-2);
}

@media (max-width: 1100px) {
    .gt-work {
        grid-template-columns: minmax(0, 1fr);
    }

    .gt-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .gt-form {
        position: static;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--gt-line);
    }

    .gt-fields {
        overflow: visible;
    }
}

@media (max-width: 768px) {
    .gt-catalog {
        padding: 28px 14px 56px;
    }

    .gt-hero h1 {
        font-size: 28px;
        line-height: 34px;
    }

    .gt-tabs {
        top: 52px;
        margin: 24px -14px 0;
        padding: 8px 14px;
    }

    .gt-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .gt-form-head,
    .gt-fields,
    .gt-form-foot {
        padding-right: 16px;
        padding-left: 16px;
    }

    .locked {
        margin-right: 16px;
        margin-left: 16px;
    }

    .gt-result {
        padding: 16px 16px 48px;
    }

    .gt-result-bar {
        top: 52px;
    }
}

/* ---------- Result while it is being written ---------- */

.output-thinking {
    display: inline-block;
    margin: 0;
    background: linear-gradient(90deg, var(--gt-text-3) 0%, var(--gt-text-3) 30%, var(--gt-text) 50%, var(--gt-text-3) 70%, var(--gt-text-3) 100%) repeat-x;
    background-size: 160% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    font-size: 16px;
    line-height: 28px;
    animation: gt-shimmer 2.8s linear infinite;
}

@keyframes gt-shimmer {
    from { background-position: 150% 0; }
    to { background-position: -116.667% 0; }
}

/* What the tool is doing while there is no text yet ("searching the web": what for) */
.output-thinking-note {
    max-width: 620px;
    margin: 8px 0 0;
    color: var(--gt-text-3);
    font-size: 15px;
    line-height: 24px;
}

/* Words fade in as they are written */
.output-rendered.gpt-live .gs-w,
.output-rendered.gpt-live pre,
.output-rendered.gpt-live table,
.output-rendered.gpt-live hr {
    animation: gt-word-in .26s ease-out;
}

@keyframes gt-word-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .output-rendered.gpt-live .gs-w,
    .output-rendered.gpt-live pre,
    .output-rendered.gpt-live table,
    .output-rendered.gpt-live hr {
        animation: none;
    }
}

.gt-btn.is-done {
    border-color: var(--gt-ok);
    color: var(--gt-ok);
}