/* =========================================================
   Local Blind Watermark — Tool UI (v2.2.0)
   ========================================================= */

.lbw-tool {
    --lbw-primary: #6366f1;
    --lbw-primary-dark: #4f46e5;
    --lbw-primary-soft: #eef2ff;
    --lbw-primary-glow: rgba(99, 102, 241, 0.18);
    --lbw-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --lbw-text: #0f172a;
    --lbw-muted: #64748b;
    --lbw-faint: #94a3b8;
    --lbw-border: #e2e8f0;
    --lbw-border-strong: #cbd5e1;
    --lbw-bg: #ffffff;
    --lbw-surface: #f8fafc;
    --lbw-radius: 18px;
    --lbw-radius-sm: 11px;
    --lbw-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px -8px rgba(15, 23, 42, 0.10);
    --lbw-shadow-hover: 0 4px 12px rgba(99, 102, 241, 0.25), 0 12px 28px -8px rgba(99, 102, 241, 0.28);

    position: relative;
    max-width: 780px;
    margin: 28px auto;
    padding: 28px;
    background: var(--lbw-bg);
    border: 1px solid var(--lbw-border);
    border-radius: var(--lbw-radius);
    box-shadow: var(--lbw-shadow);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--lbw-text);
    line-height: 1.65;
    font-size: 14px;
}
.lbw-tool *,
.lbw-tool *::before,
.lbw-tool *::after { box-sizing: border-box; }

/* ---------- Header ---------- */
.lbw-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}
.lbw-icon {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: var(--lbw-gradient);
    color: #fff;
    box-shadow: 0 6px 16px -4px rgba(99, 102, 241, 0.5);
}
.lbw-icon svg { width: 24px; height: 24px; }
.lbw-header-text { min-width: 0; }
.lbw-title {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--lbw-text);
}
.lbw-subtitle {
    margin: 3px 0 0;
    font-size: 13px;
    color: var(--lbw-muted);
}

/* ---------- Tabs ---------- */
.lbw-tabs {
    position: relative;
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 22px;
    background: var(--lbw-surface);
    border-radius: 12px;
}
.lbw-tab {
    position: relative;
    z-index: 1;
    flex: 1;
    padding: 9px 16px;
    border: 0;
    background: transparent;
    color: var(--lbw-muted);
    font-size: 14px;
    font-weight: 600;
    border-radius: 9px;
    cursor: pointer;
    transition: color .2s ease;
}
.lbw-tab:hover { color: var(--lbw-text); }
.lbw-tab-active { color: var(--lbw-primary-dark); }
.lbw-tab-indicator {
    position: absolute;
    top: 4px;
    left: 4px;
    height: calc(100% - 8px);
    background: #fff;
    border-radius: 9px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.10), 0 1px 2px rgba(15, 23, 42, 0.06);
    transition: left .28s cubic-bezier(.4, 0, .2, 1), width .28s cubic-bezier(.4, 0, .2, 1);
    pointer-events: none;
}

/* ---------- Panels ---------- */
.lbw-panel { display: block; animation: lbw-fade .28s ease; }
.lbw-hidden { display: none !important; }
@keyframes lbw-fade {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Fields ---------- */
.lbw-field { margin-bottom: 18px; }
.lbw-field-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 7px;
}
.lbw-label {
    display: block;
    margin: 0 0 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--lbw-text);
    letter-spacing: .01em;
}
.lbw-field-head .lbw-label { margin: 0; }
.lbw-counter {
    font-size: 12px;
    color: var(--lbw-faint);
    font-variant-numeric: tabular-nums;
}

.lbw-tool textarea,
.lbw-tool input[type="text"],
.lbw-tool input[type="password"] {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--lbw-border);
    border-radius: var(--lbw-radius-sm);
    background: var(--lbw-surface);
    color: var(--lbw-text);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.65;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.lbw-tool textarea::placeholder,
.lbw-tool input::placeholder { color: var(--lbw-faint); }
.lbw-tool textarea:hover,
.lbw-tool input[type="text"]:hover,
.lbw-tool input[type="password"]:hover { border-color: var(--lbw-border-strong); }
.lbw-tool textarea:focus,
.lbw-tool input[type="text"]:focus,
.lbw-tool input[type="password"]:focus {
    background: #fff;
    border-color: var(--lbw-primary);
    box-shadow: 0 0 0 4px var(--lbw-primary-glow);
}
.lbw-tool textarea {
    min-height: 128px;
    resize: vertical;
}
.lbw-tool textarea.lbw-result,
.lbw-tool textarea.lbw-output {
    min-height: 104px;
    background: var(--lbw-primary-soft);
    border-color: #dfe3ff;
    color: var(--lbw-primary-dark);
}
.lbw-tool textarea.lbw-output { color: var(--lbw-text); }
.lbw-tool textarea[readonly] { cursor: default; }

/* ---------- Redundancy selector ---------- */
.lbw-modes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.lbw-mode {
    position: relative;
    display: block;
    padding: 12px 14px;
    border: 1.5px solid var(--lbw-border);
    border-radius: var(--lbw-radius-sm);
    background: var(--lbw-surface);
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.lbw-mode:hover { border-color: var(--lbw-border-strong); background: #fff; }
.lbw-mode input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.lbw-mode-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.lbw-mode-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--lbw-text);
}
.lbw-mode-desc {
    font-size: 12px;
    color: var(--lbw-muted);
}
.lbw-mode:has(input:checked) {
    border-color: var(--lbw-primary);
    background: var(--lbw-primary-soft);
    box-shadow: 0 0 0 3px var(--lbw-primary-glow);
}
.lbw-mode:has(input:checked) .lbw-mode-title { color: var(--lbw-primary-dark); }
.lbw-mode:has(input:checked) .lbw-mode-desc { color: var(--lbw-primary); }

/* ---------- Checkbox / password wrap ---------- */
.lbw-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--lbw-text);
    cursor: pointer;
}
.lbw-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--lbw-primary);
    cursor: pointer;
}
.lbw-password-wrap {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ---------- Buttons ---------- */
.lbw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: 1px solid transparent;
    border-radius: var(--lbw-radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .2s ease, background .2s ease, color .2s ease, border-color .2s ease, opacity .2s ease;
}
.lbw-btn svg { width: 17px; height: 17px; }
.lbw-btn:active { transform: translateY(1px) scale(.99); }
.lbw-btn:disabled { opacity: .65; cursor: not-allowed; transform: none; }

.lbw-btn-primary {
    width: 100%;
    margin: 4px 0 18px;
    color: #fff;
    background: var(--lbw-gradient);
    box-shadow: 0 6px 18px -6px rgba(99, 102, 241, 0.6);
}
.lbw-btn-primary:hover:not(:disabled) {
    box-shadow: var(--lbw-shadow-hover);
    filter: brightness(1.05);
}

.lbw-btn-ghost {
    color: var(--lbw-primary-dark);
    background: var(--lbw-primary-soft);
    border-color: #dfe3ff;
}
.lbw-btn-ghost:hover {
    background: #e4e9ff;
    border-color: #c7cffd;
}

/* ---------- Actions / hint / meta ---------- */
.lbw-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: -6px;
}
.lbw-hint {
    font-size: 12.5px;
    color: var(--lbw-faint);
}
.lbw-meta {
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--lbw-muted);
}

/* ---------- Toast ---------- */
.lbw-toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translate(-50%, 20px);
    padding: 10px 20px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 10px 30px -6px rgba(15, 23, 42, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    z-index: 99999;
}
.lbw-toast-show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
    .lbw-tool { padding: 20px; margin: 16px auto; border-radius: 14px; }
    .lbw-modes { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .lbw-mode { padding: 10px 8px; text-align: center; }
    .lbw-mode-title { font-size: 13px; }
    .lbw-mode-desc { font-size: 11px; }
    .lbw-header { gap: 12px; }
    .lbw-icon { width: 40px; height: 40px; border-radius: 11px; }
    .lbw-icon svg { width: 20px; height: 20px; }
    .lbw-title { font-size: 17px; }
    .lbw-subtitle { font-size: 12px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .lbw-tool *,
    .lbw-tool *::before,
    .lbw-tool *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}