/* ── Base ─────────────────────────────────────── */
body {
    font-family: sans-serif;
    max-width: 600px;
    margin: 40px auto;
    padding: 0 20px;
    background: #f5f5f5;
    box-sizing: border-box;
}

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

h1 {
    font-size: 1.4rem;
    color: #333;
}

.card {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
}

/* ── Form elements ──────────────────────────────── */
fieldset {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
    min-width: 0;
}

legend {
    font-weight: bold;
    color: #444;
    padding: 0 6px;
}

label {
    display: block;
    margin-bottom: 4px;
    font-size: .85rem;
    font-weight: bold;
    color: #555;
}

input[type="text"],
input[type="url"],
input[type="password"],
textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: .95rem;
}

textarea {
    resize: vertical;
    font-family: monospace;
}

select {
    min-width: 0;
    max-width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: .95rem;
    background: #fff;
}

button {
    background: #4a90e2;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

button:not(:disabled):hover {
    background: #357abd;
}

button:disabled {
    background: #aaa;
    cursor: not-allowed;
}

/* ── Small / icon button ────────────────────────── */
button.btn-sm {
    padding: 4px 10px;
    font-size: .78rem;
    line-height: 1.4;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Field row ──────────────────────────────────── */
.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.field-row>div {
    flex: 1 1 200px;
}

.field-row label {
    font-size: .85rem;
    margin-bottom: 4px;
}

/* ── Result ─────────────────────────────────────── */
.result {
    margin-top: 24px;
}

.result img {
    max-width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    image-rendering: pixelated;
}

.error {
    color: #c0392b;
    margin-top: 12px;
}

.info {
    color: #27ae60;
    margin-top: 12px;
    font-size: .9rem;
}

/* ── API response ───────────────────────────────── */
.api-response {
    margin-top: 16px;
    padding: 12px;
    border-radius: 4px;
    font-family: monospace;
    font-size: .88rem;
    white-space: pre-wrap;
    word-break: break-all;
}

.api-response.ok {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.api-response.err {
    background: #fdecea;
    color: #b71c1c;
    border: 1px solid #ef9a9a;
}

/* ── Small button ───────────────────────────────── */
.btn-sm {
    font-size: .82rem;
    padding: 4px 12px;
}

.btn-sm:not(:disabled):hover {
    background: #666;
}

/* ── Tool list (index) ──────────────────────────── */
.tool-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tool-list a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    transition: background .15s, border-color .15s;
}

.tool-list a:hover {
    background: #eef4fc;
    border-color: #4a90e2;
}

.tool-list .icon {
    font-size: 1.6rem;
    line-height: 1;
}

.tool-list .label {
    font-weight: bold;
    font-size: 1rem;
}

.tool-list .desc {
    font-size: .85rem;
    color: #777;
    margin-top: 2px;
}

/* ── Crop editor (image_converter) ─────────────── */
#crop-section {
    display: none;
    margin-top: 12px;
}

#crop-wrap {
    position: relative;
    background: #111;
    border-radius: 4px;
    line-height: 0;
    overflow: hidden;
}

#crop-canvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: crosshair;
    touch-action: none;
}

.crop-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
}

.crop-info {
    font-size: .82rem;
    color: #666;
    flex: 1;
}

@media (max-width: 480px) {
    body {
        margin: 16px auto;
        padding: 0 12px;
    }

    h1 {
        font-size: 1.2rem;
        line-height: 1.35;
    }

    .card {
        padding: 16px;
    }

    fieldset {
        padding: 12px;
    }

    input[type="text"],
    input[type="url"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px;
    }

    button.btn-sm {
        padding: 6px 8px;
    }
}
