/* 配色沿用原来的 Tailwind 调色板，方便一眼认出是同一个工具 */
:root {
    --surface: #ffffff;
    --canvas: #f4f4f5;
    --line: #d4d4d8;
    --line-soft: #e4e4e7;
    --ink: #3f3f46;
    --ink-muted: #71717a;
    --ink-strong: #18181b;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-soft: #eff6ff;
    --danger: #ec4899;
    --success: #10b981;
    --neutral: #a1a1aa;
    --warn: #b45309;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 2px rgb(24 24 27 / 6%);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font: 15px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC",
        "Hiragino Sans GB", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.page {
    width: min(100% - 2rem, 860px);
    margin: 0 auto;
    padding: 2rem 0 5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.page__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.page__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink-strong);
}

.page__title sup {
    font-size: 0.6em;
}

.page__tag {
    margin: 0;
    font-size: 0.8rem;
    color: var(--ink-muted);
}

.page__tag code {
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: var(--line-soft);
    font-size: 0.95em;
    color: var(--ink);
}

.page__note {
    margin: 0;
    font-size: 0.8rem;
    color: var(--warn);
}

.panel {
    padding: 1rem;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

/* ---------- 输入区 ---------- */

.composer__input {
    display: block;
    width: 100%;
    height: 160px;
    padding: 0.5rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    color: inherit;
    resize: vertical;
}

.composer__input:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    border-color: transparent;
}

.composer__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* 输入框与文件转换区共用的状态行 */
.meta-line {
    margin: 0.6rem 0 0;
    min-height: 1.2em;
    font-size: 0.8rem;
    color: var(--ink-muted);
}

.meta-line.is-warn {
    color: var(--warn);
    font-weight: 500;
}

/* ---------- 按钮 ---------- */

.btn {
    min-width: 5rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--neutral);
    color: #fff;
    font: inherit;
    font-size: 0.9rem;
    white-space: nowrap;
    cursor: pointer;
    transition: filter 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) {
    filter: brightness(0.94);
}

.btn:focus-visible {
    outline: 2px solid var(--ink-strong);
    outline-offset: 2px;
}

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

.btn--small {
    min-width: 0;
    padding: 0.25rem 0.6rem;
    font-size: 0.85rem;
}

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

.btn--primary:hover:not(:disabled) {
    filter: none;
    background: var(--primary-dark);
}

.btn--danger {
    background: var(--danger);
}

.btn--success {
    background: var(--success);
}

.btn--muted {
    background: var(--neutral);
}

/* ---------- 储存列表 ---------- */

.store__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.store__title,
.section__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink-strong);
}

.store__meta {
    font-size: 0.8rem;
    color: var(--ink-muted);
}

.store__list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background: var(--canvas);
}

.item__body {
    min-width: 0;
}

.item__text {
    max-height: 160px;
    margin: 0;
    overflow-y: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
    font-size: 0.85rem;
}

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

.item__image {
    display: flex;
    align-items: center;
    max-height: 200px;
    margin-top: 0.6rem;
    overflow: auto;
}

.item__image img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 6px;
    object-fit: contain;
}

.item__side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.5rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--line-soft);
}

.item__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem;
}

.item__size {
    font-size: 0.75rem;
    color: var(--ink-muted);
    white-space: nowrap;
}

.store__empty {
    padding: 1.5rem;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    text-align: center;
    color: var(--ink-muted);
    font-size: 0.9rem;
}

/* ---------- 图片转 Base64 ---------- */

.section__title {
    margin-bottom: 0.35rem;
}

.section__hint {
    margin: 0 0 0.75rem;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--ink-muted);
}

.file-input {
    width: 100%;
    font-size: 0.85rem;
    color: var(--ink-muted);
}

.base64 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background: var(--canvas);
}

.base64__output {
    max-height: 100px;
    margin: 0;
    overflow: hidden;
    font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
    font-size: 0.75rem;
    color: var(--ink-muted);
    overflow-wrap: anywhere;
}

.base64__actions {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0.4rem;
}

/* 「内容不是图片」时的占位图 */
.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.placeholder__label {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--ink-strong);
    letter-spacing: 0.08em;
}

.placeholder__name {
    font-size: 0.75rem;
    color: var(--ink-muted);
    text-align: center;
    overflow-wrap: anywhere;
}

/* ---------- 全局反馈 ---------- */

.overlay {
    position: fixed;
    top: 200px;
    left: 50%;
    z-index: 50;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    background: rgb(255 255 255 / 92%);
    box-shadow: 0 8px 24px rgb(24 24 27 / 12%);
    backdrop-filter: blur(4px);
}

.overlay__text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ink);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--line-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 2s;
    }
}

.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 60;
    max-width: min(90vw, 480px);
    padding: 0.5rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    font-size: 0.9rem;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: opacity 0.2s ease;
}

.toast.is-visible {
    opacity: 1;
}

.toast[data-kind="ok"] {
    color: #047857;
}

.toast[data-kind="warn"] {
    color: var(--warn);
}

.toast[data-kind="error"] {
    color: #b91c1c;
}
