/* ===== 2026 Clean Minimal Design System ===== */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-tertiary: #f4f4f5;
    --bg-muted: #f9fafb;

    --border-default: #e4e4e7;
    --border-subtle: #f0f0f2;
    --border-focus: #18181b;

    --text-primary: #18181b;
    --text-secondary: #71717a;
    --text-muted: #a1a1aa;

    --accent-primary: #18181b;
    --accent-coral: #ff6b6b;
    --accent-success: #22c55e;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-jp: 'Noto Sans JP', 'Hiragino Kaku Gothic Pro', sans-serif;

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
}

/* ===== App Container ===== */
.app-container {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* ===== Header ===== */
.app-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-size: 24px;
}

.app-header h1 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    flex: 1;
}

.flag-pair {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ===== Tab Navigation ===== */
.tab-nav {
    display: flex;
    padding: 12px 20px;
    gap: 6px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-subtle);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn .tab-icon {
    font-size: 1rem;
}

.tab-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.25s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Card Component ===== */
.currency-card,
.translator-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

/* ===== Currency Converter ===== */
.currency-header,
.translator-header,
.allergy-header {
    margin-bottom: 24px;
}

.currency-header h2,
.translator-header h2,
.allergy-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.rate-info,
.translator-header p,
.allergy-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.currency-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.currency-input-group {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    transition: all var(--transition-fast);
}

.currency-input-group:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}

.currency-input-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.currency-flag {
    font-size: 1.125rem;
}

.currency-input-group input {
    width: 100%;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    outline: none;
}

.currency-input-group input::placeholder {
    color: var(--text-muted);
}

.swap-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin: 4px 0;
}

.swap-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: rotate(180deg);
}

.rate-display {
    margin-top: 20px;
    padding: 14px 16px;
    background: var(--bg-muted);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.rate-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.rate-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.rate-updated {
    width: 100%;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.quick-amounts {
    margin-top: 20px;
}

.quick-amounts p {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.quick-btns {
    display: flex;
    gap: 8px;
}

.quick-btn {
    flex: 1;
    padding: 10px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* ===== Voice Translator ===== */
.language-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.lang-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lang-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.lang-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.voice-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 0;
    margin-bottom: 20px;
}

.mic-btn {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
}

.mic-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.mic-btn:active {
    transform: scale(0.98);
}

.mic-btn.recording {
    background: var(--accent-coral);
    animation: pulse 1.5s infinite;
}

.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid var(--accent-primary);
    border-radius: var(--radius-full);
    opacity: 0;
}

.mic-btn.recording .pulse-ring {
    animation: pulseRing 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.3);
    }

    50% {
        box-shadow: 0 0 0 16px rgba(255, 107, 107, 0);
    }
}

@keyframes pulseRing {
    0% {
        transform: scale(1);
        opacity: 0.4;
    }

    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.mic-status {
    margin-top: 14px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.transcript-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.transcript-box {
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
}

.transcript-box label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.transcript-text {
    font-size: 0.9375rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.transcript-box.japanese {
    background: var(--bg-primary);
    border: 2px solid var(--accent-primary);
}

.japanese-text {
    font-family: var(--font-jp);
    font-size: 1.25rem;
    font-weight: 500;
}

.transcript-romaji {
    margin-top: 6px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-style: italic;
}

.arrow-down {
    display: flex;
    justify-content: center;
    color: var(--text-muted);
}

.play-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.play-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.play-btn:not(:disabled):hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ===== Allergy Card ===== */
.allergy-section {
    text-align: center;
}

.allergy-card-display {
    margin-top: 16px;
}

.allergy-card-inner {
    background: #ffffff;
    border: 2px solid var(--text-primary);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.allergy-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.allergy-title {
    font-size: 1.375rem;
    font-weight: 700;
    font-family: var(--font-jp);
    margin-bottom: 20px;
    color: var(--text-primary);
}

.allergy-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.allergy-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    text-align: left;
}

.allergy-emoji {
    font-size: 1.75rem;
    flex-shrink: 0;
}

.allergy-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.allergy-text .jp {
    font-family: var(--font-jp);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.allergy-text .en {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.allergy-message {
    font-family: var(--font-jp);
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding: 14px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
}

.allergy-message-en {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.allergy-tip {
    margin-top: 20px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 10px 16px;
    background: var(--bg-muted);
    border-radius: var(--radius-md);
    display: inline-block;
}

/* ===== Camera Translator ===== */
.camera-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.camera-header {
    margin-bottom: 20px;
}

.camera-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.camera-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.camera-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 16px;
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.camera-overlay.hidden {
    display: none;
}

.camera-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.camera-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.camera-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.camera-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.camera-btn.secondary {
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
}

.camera-btn.secondary:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

.camera-btn.active {
    background: var(--accent-coral);
}

.auto-translate-toggle {
    margin-bottom: 20px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.toggle-label input {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.toggle-label input:checked+.toggle-switch {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle-label input:checked+.toggle-switch::after {
    transform: translateX(20px);
}

.translation-result {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 16px;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-muted);
    border-bottom: 1px solid var(--border-default);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.result-icon {
    font-size: 1rem;
}

.result-content {
    padding: 16px;
}

.detected-text {
    font-family: var(--font-jp);
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.6;
}

.result-divider {
    height: 1px;
    background: var(--border-default);
    margin: 12px 0;
}

.translated-text {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.translation-result.loading .result-content {
    opacity: 0.5;
}

.cost-tracker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-muted);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cost-tracker strong {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ===== Footer ===== */
.app-footer {
    padding: 16px 20px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-subtle);
}

.app-footer p {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 360px) {
    .currency-input-group input {
        font-size: 1.5rem;
    }

    .quick-btn {
        padding: 8px 4px;
        font-size: 0.8125rem;
    }
}

/* ===== Safe Area ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .app-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}