/* Auto jin Tools - Text & Design Tools CSS
 * Supports: qr-code, markdown-preview, text-counter, romanization, special-characters,
 * color-converter, color-palette, color-extractor, dummy-image.
 */

/* Sub-navigation & Mode Tabs */
.td-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--tool-border);
    border-radius: 8px;
    background: #f7f8fa;
    margin-bottom: 16px;
}
.td-tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 16px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #4d5159;
    font-size: .84rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}
.td-tab-btn:hover {
    color: var(--tool-ink);
}
.td-tab-btn.is-active {
    background: var(--tool-brand);
    color: #ffffff;
}

/* Controls Grid */
.td-controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.td-color-picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.td-color-picker-row input[type="color"] {
    width: 44px;
    height: 44px;
    padding: 2px;
    border: 1px solid var(--tool-border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}
.td-color-picker-row input[type="text"] {
    flex: 1;
    min-width: 0;
}

/* QR Code Tool */
.td-qr-preview-box {
    display: grid;
    place-items: center;
    padding: 24px;
    border: 1px solid var(--tool-border);
    border-radius: 12px;
    background: #fbfcfe;
    min-height: 280px;
}
.td-qr-preview-box canvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
.td-qr-preview-meta {
    margin-top: 12px;
    color: var(--tool-muted);
    font-size: .82rem;
    text-align: center;
}
.td-qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
}
.td-qr-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--tool-border);
    border-radius: 8px;
    background: #ffffff;
    text-align: center;
}
.td-qr-card canvas {
    width: 100%;
    max-width: 120px;
    height: auto;
    border-radius: 4px;
}
.td-qr-card-title {
    margin-top: 8px;
    font-size: .75rem;
    font-weight: 700;
    color: var(--tool-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}
.td-qr-card-sub {
    font-size: .7rem;
    color: var(--tool-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

/* Markdown Preview Tool */
.td-md-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.td-md-editor textarea {
    min-height: 380px;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: .86rem;
    line-height: 1.6;
}
.td-md-preview {
    min-height: 380px;
    padding: 20px;
    border: 1px solid var(--tool-border);
    border-radius: 12px;
    background: #ffffff;
    overflow-y: auto;
    line-height: 1.7;
    font-size: .92rem;
}
.td-md-preview h1 { font-size: 1.6rem; border-bottom: 1px solid #eaecef; padding-bottom: .3em; margin-top: 0; }
.td-md-preview h2 { font-size: 1.35rem; border-bottom: 1px solid #eaecef; padding-bottom: .3em; }
.td-md-preview h3 { font-size: 1.15rem; }
.td-md-preview pre {
    background: #212124;
    color: #f7f8fa;
    padding: 14px;
    border-radius: 8px;
    overflow-x: auto;
}
.td-md-preview code {
    background: #f0f2f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: .84em;
    font-family: "SFMono-Regular", Consolas, monospace;
}
.td-md-preview pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}
.td-md-preview blockquote {
    margin: 0;
    padding: 0 1em;
    color: #656971;
    border-left: .25em solid #dfe2e5;
}
.td-md-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
}
.td-md-preview th, .td-md-preview td {
    padding: 8px 12px;
    border: 1px solid #dfe2e5;
}
.td-md-preview th {
    background: #f7f8fa;
    font-weight: 700;
}
.td-md-preview img {
    max-width: 100%;
    height: auto;
}

/* Text Counter SNS Hints */
.td-sns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.td-sns-card {
    padding: 14px;
    border: 1px solid var(--tool-border);
    border-radius: 10px;
    background: #fbfcfe;
}
.td-sns-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .82rem;
    font-weight: 700;
    color: var(--tool-ink);
}
.td-sns-status {
    font-size: .75rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
}
.td-sns-status.is-ok {
    background: #e6f6ee;
    color: #127943;
}
.td-sns-status.is-warn {
    background: #fef0e6;
    color: #c44d00;
}
.td-sns-status.is-over {
    background: #fde8e8;
    color: #c81e1e;
}
.td-sns-bar {
    height: 6px;
    border-radius: 999px;
    background: #eaebee;
    overflow: hidden;
    margin: 10px 0 6px;
}
.td-sns-bar-fill {
    height: 100%;
    background: var(--tool-brand);
    transition: width 150ms ease, background 150ms ease;
}
.td-sns-bar-fill.is-over {
    background: #e02424;
}
.td-sns-footer {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    color: var(--tool-muted);
}

/* Special Characters */
.td-char-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.td-char-pill {
    padding: 6px 12px;
    border: 1px solid var(--tool-border);
    border-radius: 999px;
    background: #fff;
    color: #4d5159;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease;
}
.td-char-pill:hover {
    border-color: #9da1a8;
}
.td-char-pill.is-active {
    background: var(--tool-brand);
    border-color: var(--tool-brand);
    color: #ffffff;
}
.td-char-multibar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 12px 14px;
    border: 1.5px solid var(--tool-brand);
    border-radius: 10px;
    background: #fff7f2;
    margin-bottom: 14px;
}
.td-char-multibar input {
    flex: 1;
    min-width: 140px;
    font-size: 1.1rem;
    padding: 8px 12px;
    border: 1px solid var(--tool-border);
    border-radius: 6px;
    background: #fff;
}
.td-char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 6px;
    max-height: 480px;
    overflow-y: auto;
    padding: 4px;
}
.td-char-btn {
    display: grid;
    place-items: center;
    height: 48px;
    padding: 0;
    border: 1px solid var(--tool-border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--tool-ink);
    font-size: 1.25rem;
    cursor: pointer;
    transition: transform 90ms ease, border-color 90ms ease, background 90ms ease;
    user-select: none;
}
.td-char-btn:hover {
    border-color: var(--tool-brand);
    background: #fff7f2;
    transform: translateY(-1px);
}
.td-char-btn:active {
    transform: translateY(1px);
}
.td-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    pointer-events: none;
    background: rgba(33, 33, 36, 0.92);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: .84rem;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: opacity 160ms ease, transform 160ms ease;
    z-index: 9999;
}
.td-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Color Converter & Contrast Checker */
.td-color-display-card {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 16px;
    align-items: center;
    padding: 18px;
    border: 1px solid var(--tool-border);
    border-radius: 12px;
    background: #fbfcfe;
}
.td-color-swatch-box {
    width: 100%;
    height: 120px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.td-color-format-list {
    display: grid;
    gap: 8px;
}
.td-color-format-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--tool-border);
    border-radius: 8px;
    background: #fff;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: .82rem;
}
.td-color-format-label {
    font-weight: 800;
    color: var(--tool-muted);
    min-width: 50px;
}
.td-color-format-val {
    flex: 1;
    color: var(--tool-ink);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.td-contrast-container {
    margin-top: 20px;
    padding: 18px;
    border: 1px solid var(--tool-border);
    border-radius: 12px;
    background: #fbfcfe;
}
.td-contrast-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}
.td-contrast-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 800;
    border: 1px solid transparent;
}
.td-contrast-badge.is-pass {
    background: #e6f6ee;
    color: #127943;
    border-color: #b3e3cd;
}
.td-contrast-badge.is-fail {
    background: #fde8e8;
    color: #c81e1e;
    border-color: #f7b4b4;
}
.td-contrast-preview-box {
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--tool-border);
    margin-top: 10px;
}
.td-contrast-preview-lg {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 6px;
}
.td-contrast-preview-sm {
    font-size: .9rem;
    line-height: 1.5;
}

/* Color Palette Schemes */
.td-palette-section {
    margin-top: 18px;
}
.td-palette-section h3 {
    margin: 0 0 8px;
    font-size: .95rem;
    color: var(--tool-ink);
}
.td-palette-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.td-palette-chip {
    flex: 1;
    min-width: 80px;
    display: flex;
    flex-direction: column;
    padding: 6px;
    border: 1px solid var(--tool-border);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    transition: transform 100ms ease, box-shadow 100ms ease;
}
.td-palette-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}
.td-palette-chip-swatch {
    height: 48px;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.td-palette-chip-hex {
    margin-top: 6px;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: .72rem;
    font-weight: 700;
    color: var(--tool-ink);
    text-align: center;
}

/* Color Extractor */
.td-extract-list {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}
.td-extract-item {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 14px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--tool-border);
    border-radius: 10px;
    background: #ffffff;
}
.td-extract-thumb {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    background: #f2f3f6;
    border: 1px solid var(--tool-border);
}
.td-extract-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.td-extract-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid var(--tool-border);
    border-radius: 6px;
    background: #fbfcfe;
    cursor: pointer;
    font-size: .74rem;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-weight: 700;
}
.td-extract-chip:hover {
    border-color: var(--tool-brand);
}
.td-extract-chip-color {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}
.td-extract-share {
    color: var(--tool-muted);
    font-size: .68rem;
}

/* Dummy Image Presets */
.td-preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    margin: 12px 0;
}
.td-preset-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--tool-border);
    border-radius: 8px;
    background: #fbfcfe;
    font-size: .82rem;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
}
.td-preset-label:hover {
    border-color: #9da1a8;
}
.td-preset-label input:checked + span {
    color: var(--tool-brand);
    font-weight: 800;
}
.td-dummy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 16px;
}
.td-dummy-card {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border: 1px solid var(--tool-border);
    border-radius: 10px;
    background: #ffffff;
}
.td-dummy-thumb-wrap {
    display: grid;
    place-items: center;
    background: #f2f3f6;
    border-radius: 6px;
    padding: 8px;
    min-height: 120px;
    overflow: hidden;
}
.td-dummy-thumb-wrap img, .td-dummy-thumb-wrap svg {
    max-width: 100%;
    max-height: 140px;
    object-fit: contain;
    border-radius: 4px;
}
.td-dummy-card-meta {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .8rem;
    font-weight: 700;
}

/* Dark Mode Overrides */
html[data-theme="dark"] .td-tabs {
    border-color: #303236;
    background: #202226;
}
html[data-theme="dark"] .td-tab-btn {
    color: #c8c9cc;
}
html[data-theme="dark"] .td-qr-preview-box,
html[data-theme="dark"] .td-color-display-card,
html[data-theme="dark"] .td-contrast-container,
html[data-theme="dark"] .td-sns-card,
html[data-theme="dark"] .td-preset-label {
    border-color: #303236;
    background: #202226;
}
html[data-theme="dark"] .td-qr-card,
html[data-theme="dark"] .td-md-preview,
html[data-theme="dark"] .td-char-btn,
html[data-theme="dark"] .td-char-pill,
html[data-theme="dark"] .td-color-format-row,
html[data-theme="dark"] .td-palette-chip,
html[data-theme="dark"] .td-extract-item,
html[data-theme="dark"] .td-extract-chip,
html[data-theme="dark"] .td-dummy-card {
    border-color: #303236;
    background: #1a1c20;
    color: #f7f8fa;
}
html[data-theme="dark"] .td-char-multibar {
    border-color: var(--tool-brand);
    background: #2c1b12;
}
html[data-theme="dark"] .td-char-multibar input {
    border-color: #303236;
    background: #202226;
    color: #f7f8fa;
}
html[data-theme="dark"] .td-md-preview th {
    background: #25272b;
    border-color: #383b42;
}
html[data-theme="dark"] .td-md-preview td {
    border-color: #383b42;
}
html[data-theme="dark"] .td-md-preview code {
    background: #282a30;
}
html[data-theme="dark"] .td-dummy-thumb-wrap {
    background: #25272b;
}

/* Responsiveness (Mobile ≤ 680px and 390px) */
@media (max-width: 680px) {
    .td-md-container {
        grid-template-columns: 1fr;
    }
    .td-color-display-card {
        grid-template-columns: 1fr;
    }
    .td-color-swatch-box {
        height: 80px;
    }
    .td-extract-item {
        grid-template-columns: 1fr;
    }
    .td-extract-thumb {
        width: 100%;
        height: 120px;
    }
}
