/* SearchGPT For Me: hand-written styles, no framework. */
:root {
    --bg: #f3f4f6;
    --card: #ffffff;
    --text: #1f2937;
    --text-soft: #374151;
    --muted: #6b7280;
    --border: #d1d5db;
    --border-light: #e5e7eb;
    --surface: #f9fafb;
    --blue: #3b82f6;
    --blue-hover: #2563eb;
    --blue-muted: #93c5fd;
    --green: #22c55e;
    --green-hover: #16a34a;
    --green-muted: #86efac;
    --purple: #9333ea;
    --purple-hover: #7e22ce;
    --amber-bg: #fffbeb;
    --amber-border: #fde68a;
    --amber-text: #92400e;
    --success-text: #15803d;
    --surface-hover: #f3f4f6;
    --code-bg: #f3f4f6;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.1);
    --icon-invert: 0;
    --radius: 0.375rem;
    color-scheme: light;
}

/* Dark theme: chosen explicitly (data-theme) or by the system when nothing is chosen */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #111827;
        --card: #1f2937;
        --text: #f3f4f6;
        --text-soft: #d1d5db;
        --muted: #9ca3af;
        --border: #4b5563;
        --border-light: #374151;
        --surface: #111827;
        --surface-hover: #273449;
        --amber-bg: #3b2a06;
        --amber-border: #92400e;
        --amber-text: #fcd34d;
        --success-text: #4ade80;
        --code-bg: #374151;
        --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);
        --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.5);
        --icon-invert: 1;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #111827;
    --card: #1f2937;
    --text: #f3f4f6;
    --text-soft: #d1d5db;
    --muted: #9ca3af;
    --border: #4b5563;
    --border-light: #374151;
    --surface: #111827;
    --surface-hover: #273449;
    --amber-bg: #3b2a06;
    --amber-border: #92400e;
    --amber-text: #fcd34d;
    --success-text: #4ade80;
    --code-bg: #374151;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.5);
    --icon-invert: 1;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    transition: background-color 0.2s, color 0.2s;
    min-height: 100vh;
    padding: 2rem 1rem;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
}

a {
    color: var(--blue);
    text-decoration: none;
}

:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    margin: 0;
    line-height: 1.25;
}

.container {
    max-width: 48rem;
    margin: 0 auto;
}

/* Cards */
.card {
    padding: 1.5rem;
    background: var(--card);
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
}

.card + .card {
    margin-top: 2rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.card-header h1 {
    flex: 1;
    font-size: 1.5rem;
    font-weight: 700;
}

.card-header.centered h1 {
    text-align: center;
}

.card-header .github {
    flex: none;
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: none;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
}

.theme-toggle:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: inline; }
:root[data-theme="dark"] .theme-toggle .sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

.lang {
    max-width: 9rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--muted);
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}

.lang:hover {
    color: var(--text);
}

.tagline {
    margin: 0 0 1rem;
    text-align: center;
    color: var(--muted);
}

/* Query form */
.query {
    display: block;
    width: 100%;
    min-height: 4.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    resize: vertical;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

@media (min-width: 640px) {
    .actions {
        flex-direction: row;
    }
}

.btn {
    display: inline-block;
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: var(--radius);
    color: #ffffff;
    font: inherit;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.15s;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary { background: var(--blue); }
.btn-primary:hover { background: var(--blue-hover); }
.btn-accent { background: var(--purple); }
.btn-accent:hover { background: var(--purple-hover); }
.btn-copy { background: var(--green); }
.btn-copy:hover { background: var(--green-hover); }
.btn-muted.btn-primary { background: var(--blue-muted); }
.btn-muted.btn-copy { background: var(--green-muted); }

.btn-sm {
    flex: none;
    padding: 0.25rem 0.75rem;
    white-space: nowrap;
}

.settings {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.settings-label {
    font-weight: 500;
}

.settings-option {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}

.icon-xs { width: 1rem; height: 1rem; }
.icon-sm { width: 1.25rem; height: 1.25rem; flex: none; }
.icon { width: 1.5rem; height: 1.5rem; flex: none; }
.icon-lg { width: 2rem; height: 2rem; }

/* Black-on-transparent logos disappear on dark cards: invert them there */
.icon-mono {
    filter: invert(var(--icon-invert));
}

.notice {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.notice-warning {
    color: var(--amber-text);
    background: var(--amber-bg);
    border: 1px solid var(--amber-border);
}

.notice-success {
    margin: 0.5rem 0 0;
    padding: 0;
    color: var(--success-text);
}

.hint {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    color: var(--muted);
}

/* Generated links */
.results {
    margin-top: 1.5rem;
}

.directory {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.directory-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    padding: 0.5rem 0.625rem;
    background: var(--surface);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9375rem;
}

.directory-item:hover {
    background: var(--surface-hover);
    text-decoration: none;
}

.directory-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bookmarklet {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    cursor: grab;
}

.bookmarklet:hover {
    text-decoration: none;
    background: var(--surface-hover);
}

.group-title {
    margin: 1rem 0 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.result-item {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.result-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-row + .result-row {
    margin-top: 0.25rem;
}

.result-link {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.result-box {
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-soft);
    overflow-wrap: anywhere;
}

/* Long-form content */
.prose {
    line-height: 1.625;
}

.prose h2 {
    margin: 1.5rem 0 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.prose h2:first-child {
    margin-top: 0;
}

.prose h3 {
    margin: 1rem 0 0.25rem;
    font-weight: 600;
}

.prose p,
.prose ol,
.prose ul {
    margin: 0 0 0.75rem;
}

.prose ol {
    padding-left: 1.25rem;
}

.prose ul {
    padding: 0;
    list-style: none;
}

.prose li + li {
    margin-top: 0.25rem;
}

.prose ul li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.prose code {
    padding: 0 0.25rem;
    background: var(--code-bg);
    border-radius: 0.25rem;
    font-size: 0.9em;
    overflow-wrap: anywhere;
}

.table-wrap {
    overflow-x: auto;
}

.prose table {
    width: 100%;
    margin-bottom: 0.75rem;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.prose th,
.prose td {
    padding: 0.5rem 0.75rem 0.5rem 0;
    text-align: left;
    vertical-align: top;
}

.prose thead tr {
    border-bottom: 1px solid var(--border-light);
}

.prose tbody tr:not(:last-child) {
    border-bottom: 1px solid var(--bg);
}

.breadcrumb {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.muted {
    font-size: 0.875rem;
    color: var(--muted);
}

.footer {
    margin: 1.5rem 0 0.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--muted);
}

.hidden {
    display: none !important;
}
