/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1e3a5f;
    --primary-light: #2a4d7a;
    --primary-dark: #0f2740;
    --accent: #d4a843;
    --accent-light: #e8c46a;
    --accent-dark: #b8922e;
    --bg: #f4f7fc;
    --card-bg: #ffffff;
    --text: #1a2332;
    --text-muted: #6b7a8f;
    --border: #dce3ed;
    --shadow: 0 8px 32px rgba(30, 58, 95, 0.10);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

/* ===== App Container ===== */
.app-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Header ===== */
.app-header {
    padding: 40px 0 24px;
    text-align: center;
}

.header-content h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    letter-spacing: -0.02em;
}

.header-content h1 i {
    color: var(--accent);
    font-size: 1.8rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 4px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* ===== Main ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding-bottom: 40px;
}

/* ===== Converter Card ===== */
.converter-card {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
    overflow: hidden;
    border: 1px solid rgba(212, 168, 67, 0.15);
    transition: box-shadow var(--transition);
}

.converter-card:hover {
    box-shadow: 0 12px 40px rgba(30, 58, 95, 0.13);
}

.card-glow {
    position: absolute;
    top: -60px;
    right: -60px;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(212, 168, 67, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

/* ===== Input Section ===== */
.input-section {
    margin-bottom: 28px;
}

.input-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.input-label i {
    margin-right: 6px;
    color: var(--accent);
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    transition: border-color var(--transition), box-shadow var(--transition);
    padding: 0 4px 0 16px;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(212, 168, 67, 0.15);
}

.currency-prefix {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary);
    padding-right: 6px;
    user-select: none;
}

#amount-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 16px 8px;
    font-size: 1.25rem;
    font-weight: 600;
    font-family: var(--font);
    color: var(--text);
    outline: none;
    min-width: 0;
}

#amount-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.95rem;
    opacity: 0.7;
}

.clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 12px 14px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition), color var(--transition);
}

.clear-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

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

/* ===== Quick Amounts ===== */
.quick-amounts {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.quick-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.quick-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--primary-dark);
    transform: translateY(-1px);
}

.quick-btn:active {
    transform: translateY(0);
}

/* ===== Output Section ===== */
.output-section {
    position: relative;
}

.output-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.output-label i {
    margin-right: 6px;
    color: var(--accent);
}

.result-display {
    background: linear-gradient(135deg, #f8fafd 0%, #f1f4f9 100%);
    border-radius: var(--radius-sm);
    padding: 20px 22px;
    min-height: 72px;
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.result-display.has-result {
    background: linear-gradient(135deg, #fdf9ee 0%, #f8f1dc 100%);
    border-color: var(--accent);
}

.placeholder-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    opacity: 0.6;
    font-style: italic;
}

#result-display .result-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-dark);
    line-height: 1.5;
    word-break: break-word;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-xs);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.2);
}

.action-btn:hover:not(:disabled) {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(30, 58, 95, 0.25);
}

.action-btn:active:not(:disabled) {
    transform: translateY(0);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.action-btn i {
    font-size: 1rem;
}

.secondary-btn {
    background: var(--bg);
    color: var(--text);
    box-shadow: none;
    border: 1px solid var(--border);
}

.secondary-btn:hover {
    background: #e8ecf2;
    border-color: var(--text-muted);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.08);
}

.secondary-btn:active {
    transform: translateY(0);
}

/* ===== Toast ===== */
.toast-message {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    background: var(--primary-dark);
    color: #fff;
    padding: 8px 20px;
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    white-space: nowrap;
}

.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== Info Section ===== */
.info-section {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.info-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.06);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.info-card i {
    color: var(--accent);
    font-size: 1rem;
}

/* ===== History Section ===== */
.history-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 28px;
    border: 1px solid var(--border);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.history-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-header h2 i {
    color: var(--accent);
    font-size: 1rem;
}

.small-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    display: flex;
    align-items: center;
    gap: 6px;
}

.small-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius-xs);
    transition: background var(--transition);
    gap: 12px;
}

.history-item:hover {
    background: #eef2f7;
}

.history-num {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.95rem;
    white-space: nowrap;
}

.history-zh {
    color: var(--text);
    font-size: 0.85rem;
    flex: 1;
    text-align: right;
    word-break: break-word;
    line-height: 1.4;
}

.history-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 20px 0;
    opacity: 0.6;
}

/* ===== Footer ===== */
.app-footer {
    text-align: center;
    padding: 24px 0 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .app-container {
        padding: 0 14px;
    }

    .app-header {
        padding: 28px 0 18px;
    }

    .header-content h1 {
        font-size: 1.5rem;
    }

    .converter-card {
        padding: 24px 18px;
    }

    #amount-input {
        font-size: 1.1rem;
        padding: 14px 6px;
    }

    .result-display {
        padding: 16px 18px;
        min-height: 60px;
    }

    #result-display .result-text {
        font-size: 1rem;
    }

    .action-btn {
        padding: 10px 18px;
        font-size: 0.85rem;
        flex: 1;
        justify-content: center;
    }

    .quick-amounts {
        gap: 6px;
    }

    .quick-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    .history-section {
        padding: 18px 16px;
    }

    .history-item {
        padding: 10px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .history-zh {
        text-align: left;
        width: 100%;
    }

    .info-section {
        gap: 8px;
    }

    .info-card {
        padding: 10px 14px;
        font-size: 0.78rem;
    }

    .toast-message {
        font-size: 0.78rem;
        padding: 6px 16px;
    }
}

@media (min-width: 768px) {
    .converter-card {
        padding: 40px 36px;
    }

    .history-item {
        flex-direction: row;
    }

    .history-zh {
        text-align: right;
    }
}

@media (min-width: 1200px) {
    .app-container {
        max-width: 800px;
    }
}