:root {
    --bg-base: #f5f1e8;
    --bg-accent: #fdfaf4;
    --surface: rgba(255, 250, 244, 0.9);
    --surface-strong: #fffdf9;
    --surface-muted: rgba(255, 255, 255, 0.72);
    --border-soft: rgba(64, 48, 34, 0.12);
    --border-strong: rgba(64, 48, 34, 0.22);
    --text-primary: #1f2933;
    --text-secondary: #52606d;
    --text-muted: #7b8794;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --accent-soft: rgba(15, 118, 110, 0.14);
    --accent-warm: #d97706;
    --accent-warm-soft: rgba(217, 119, 6, 0.12);
    --danger: #c2410c;
    --danger-soft: rgba(194, 65, 12, 0.12);
    --success: #15803d;
    --success-soft: rgba(21, 128, 61, 0.12);
    --shadow-soft: 0 16px 40px rgba(31, 41, 51, 0.08);
    --shadow-strong: 0 24px 60px rgba(31, 41, 51, 0.14);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --content-width: 1180px;
    --transition-fast: 180ms ease;
    --transition-medium: 280ms ease;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Manrope', sans-serif;
    color: var(--text-primary);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 28%),
        radial-gradient(circle at top right, rgba(217, 119, 6, 0.12), transparent 24%),
        linear-gradient(180deg, var(--bg-accent) 0%, var(--bg-base) 100%);
    line-height: 1.6;
}

body.modal-open {
    overflow: hidden;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    border: 0;
    background: none;
    cursor: pointer;
}

img,
svg {
    display: block;
    max-width: 100%;
}

.hidden {
    display: none !important;
}

.page-shell {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 20px 20px 40px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 18px 22px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 20px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(255, 250, 244, 0.92)),
        linear-gradient(135deg, rgba(15, 118, 110, 0.04), rgba(217, 119, 6, 0.06));
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}

.brand-block {
    display: grid;
    gap: 4px;
}

.eyebrow {
    margin: 0 0 10px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.78rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--accent);
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: clamp(2.1rem, 4vw, 3.2rem);
    line-height: 0.96;
    letter-spacing: -0.05em;
}

.auth-state {
    padding: 8px 12px;
    border: 1px solid rgba(15, 118, 110, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.74rem;
    color: var(--text-secondary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.workspace {
    margin-top: 14px;
    display: grid;
    gap: 14px;
}

.toolbar-panel,
.prompt-card,
.status-banner,
.empty-state,
.modal-content,
.toast {
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}

.toolbar-panel {
    display: grid;
    gap: 14px;
    padding: 18px 20px;
    border-radius: var(--radius-lg);
}

.compact-panel {
    gap: 12px;
}

.toolbar-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.toolbar-title-group {
    display: grid;
    gap: 4px;
}

.toolbar-title-group h2 {
    font-size: clamp(1.45rem, 2vw, 1.9rem);
    line-height: 1.05;
    letter-spacing: -0.03em;
}

.result-meta {
    max-width: none;
    text-align: right;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.search-form {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.field {
    display: grid;
    gap: 6px;
}

.field-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
}

.field-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.78);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

input,
select {
    min-height: 48px;
    padding: 0 14px;
}

textarea {
    min-height: 240px;
    padding: 16px;
    resize: vertical;
    font-family: 'IBM Plex Mono', monospace;
    line-height: 1.7;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.btn:focus-visible,
.prompt-card:focus-visible,
.filter-chip:focus-visible,
.close-btn:focus-visible,
.tag-suggestion-item:focus-visible {
    outline: none;
    border-color: rgba(15, 118, 110, 0.4);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.search-actions,
.form-actions,
.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.search-actions {
    justify-content: flex-end;
    align-items: end;
}

.btn {
    min-height: 46px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 700;
    transition:
        transform var(--transition-fast),
        background var(--transition-fast),
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        color var(--transition-fast),
        opacity var(--transition-fast);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 12px 28px rgba(15, 118, 110, 0.22);
}

.btn-primary:hover {
    background: var(--accent-strong);
}

.btn-secondary {
    border-color: rgba(64, 48, 34, 0.12);
    background: rgba(255, 255, 255, 0.75);
    color: var(--text-primary);
}

.btn-secondary:hover {
    border-color: rgba(15, 118, 110, 0.22);
    color: var(--accent-strong);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 12px 28px rgba(194, 65, 12, 0.2);
}

.btn-danger:hover {
    background: #9a3412;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(15, 118, 110, 0.18);
    background: rgba(15, 118, 110, 0.08);
    color: var(--accent-strong);
    font-weight: 700;
}

.filter-chip span {
    max-width: 24ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-banner {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
}

.status-banner-error {
    border-color: rgba(194, 65, 12, 0.18);
    background: rgba(194, 65, 12, 0.08);
}

.status-banner-info {
    border-color: rgba(15, 118, 110, 0.18);
    background: rgba(15, 118, 110, 0.08);
}

.prompt-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.prompt-card {
    display: grid;
    gap: 18px;
    padding: 22px;
    border-radius: var(--radius-lg);
    transition: transform var(--transition-medium), box-shadow var(--transition-medium), border-color var(--transition-fast);
}

.prompt-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-strong);
    border-color: rgba(15, 118, 110, 0.16);
}

.card-top,
.card-footer,
.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.version-pill,
.meta-pill,
.tag {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.version-pill {
    background: rgba(15, 118, 110, 0.1);
    color: var(--accent-strong);
}

.meta-pill {
    background: rgba(217, 119, 6, 0.1);
    color: #9a3412;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(64, 48, 34, 0.1);
    background: rgba(255, 255, 255, 0.75);
    color: var(--text-secondary);
}

.icon-button:hover {
    border-color: rgba(15, 118, 110, 0.2);
    color: var(--accent-strong);
}

.prompt-title {
    font-size: 1.45rem;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.prompt-content {
    color: var(--text-secondary);
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.prompt-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.prompt-tags-static {
    min-height: 28px;
}

.tag {
    background: rgba(82, 96, 109, 0.08);
    color: var(--text-secondary);
}

.card-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.text-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    font-weight: 700;
    color: var(--accent-strong);
}

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

.empty-state {
    grid-column: 1 / -1;
    width: 100%;
    padding: 44px 24px;
    border-radius: var(--radius-lg);
    text-align: center;
}

.empty-state h3 {
    font-size: 1.6rem;
    letter-spacing: -0.03em;
}

.empty-state p {
    margin-top: 12px;
    color: var(--text-secondary);
}

.skeleton {
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.48), transparent);
    animation: shimmer 1.4s infinite;
}

.skeleton-block {
    border-radius: 999px;
    background: rgba(82, 96, 109, 0.1);
}

.skeleton-title {
    width: 72%;
    height: 26px;
    border-radius: 10px;
}

.skeleton-line {
    width: 100%;
    height: 14px;
}

.skeleton-line.short {
    width: 64%;
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: grid;
    gap: 10px;
    z-index: 2100;
}

.toast {
    min-width: 260px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity var(--transition-medium), transform var(--transition-medium);
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: rgba(21, 128, 61, 0.12);
    border-color: rgba(21, 128, 61, 0.2);
}

.toast-error {
    background: rgba(194, 65, 12, 0.12);
    border-color: rgba(194, 65, 12, 0.2);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(31, 41, 51, 0.34);
    backdrop-filter: blur(10px);
}

.modal.open {
    display: flex;
}

.modal-content {
    position: relative;
    width: min(960px, 100%);
    max-height: min(88vh, 920px);
    padding: 28px;
    border-radius: var(--radius-xl);
    overflow: auto;
}

.prompt-modal,
.login-modal,
.confirm-modal {
    width: min(720px, 100%);
}

.login-modal,
.confirm-modal {
    width: min(480px, 100%);
}

.modal-heading {
    display: grid;
    gap: 10px;
}

.modal-heading h2,
.detail-header h2 {
    font-size: clamp(2rem, 4vw, 2.8rem);
    line-height: 1;
    letter-spacing: -0.04em;
}

.modal-description {
    max-width: 56ch;
    color: var(--text-secondary);
}

.modal-body {
    display: grid;
    gap: 18px;
    margin-top: 24px;
}

.close-btn {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(64, 48, 34, 0.12);
    background: rgba(255, 255, 255, 0.86);
    color: var(--text-muted);
}

.close-btn:hover {
    color: var(--text-primary);
}

.form-actions {
    margin-top: 6px;
    justify-content: flex-end;
}

.inline-feedback {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
}

.inline-feedback-error {
    border: 1px solid rgba(194, 65, 12, 0.18);
    background: rgba(194, 65, 12, 0.08);
    color: #9a3412;
}

.detail-modal {
    width: min(1120px, 100%);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding-right: 56px;
}

.detail-layout {
    display: grid;
    grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
    gap: 20px;
    margin-top: 24px;
}

.detail-sidebar {
    display: grid;
    gap: 14px;
    align-content: start;
}

.detail-panel {
    padding: 18px;
    border: 1px solid rgba(64, 48, 34, 0.08);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.54);
}

.detail-meta {
    display: grid;
    gap: 10px;
}

.detail-meta-item {
    display: grid;
    gap: 4px;
}

.detail-meta-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
}

.detail-meta-value {
    color: var(--text-primary);
    font-weight: 700;
}

.detail-content {
    min-height: 420px;
    padding: 24px;
    border: 1px solid rgba(64, 48, 34, 0.08);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.58);
}

.detail-content-empty {
    display: grid;
    place-items: center;
    color: var(--text-muted);
}

.preview {
    display: grid;
    gap: 18px;
    color: var(--text-secondary);
}

.preview h1,
.preview h2,
.preview h3,
.preview h4 {
    color: var(--text-primary);
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.preview p,
.preview ul,
.preview ol,
.preview blockquote,
.preview pre {
    margin: 0;
}

.preview ul,
.preview ol {
    padding-left: 20px;
}

.preview code {
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(15, 118, 110, 0.1);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9em;
    color: var(--accent-strong);
}

.preview pre {
    overflow: auto;
    padding: 16px;
    border-radius: var(--radius-md);
    background: #18362f;
    color: #f2f8f6;
}

.preview pre code {
    padding: 0;
    background: transparent;
    color: inherit;
}

.version-dropdown {
    min-height: 48px;
}

.confirm-modal .form-actions {
    margin-top: 20px;
}

.tag-suggestions {
    position: absolute;
    z-index: 2200;
    display: none;
    max-height: 220px;
    overflow: auto;
    padding: 6px;
    border: 1px solid rgba(64, 48, 34, 0.12);
    border-radius: var(--radius-md);
    background: var(--surface-strong);
    box-shadow: var(--shadow-strong);
}

.tag-suggestions.visible {
    display: grid;
}

.tag-suggestion-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-primary);
    text-align: left;
}

.tag-suggestion-item:hover,
.tag-suggestion-item.active {
    background: rgba(15, 118, 110, 0.1);
    color: var(--accent-strong);
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

@media (max-width: 960px) {
    .search-form,
    .detail-layout {
        grid-template-columns: 1fr;
    }

    .topbar,
    .topbar-actions,
    .topbar-buttons,
    .toolbar-head,
    .detail-header {
        justify-content: flex-start;
    }

    .topbar,
    .topbar-actions,
    .toolbar-head,
    .detail-header {
        align-items: start;
        flex-direction: column;
    }

    .result-meta {
        text-align: left;
    }

    .search-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .page-shell {
        padding: 14px 14px 28px;
    }

    .topbar,
    .toolbar-panel,
    .modal-content,
    .prompt-card,
    .detail-content {
        padding: 20px;
    }

    h1 {
        font-size: 2.4rem;
    }

    .result-meta {
        font-size: 0.95rem;
    }

    .detail-actions,
    .form-actions,
    .topbar-buttons,
    .search-actions {
        width: 100%;
    }

    .detail-actions .btn,
    .form-actions .btn,
    .topbar-buttons .btn,
    .search-actions .btn {
        flex: 1 1 100%;
    }

    .modal {
        padding: 12px;
    }

    .close-btn {
        top: 12px;
        right: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
