/* ========================================
   CSS Variables & Base Styles
======================================== */
:root {
    --color-bg: #0f1419;
    --color-surface: #1a2028;
    --color-surface-elevated: #242d38;
    --color-border: #2f3b4a;
    --color-text: #e8edf4;
    --color-text-muted: #8b98a8;
    --color-primary: #00d4aa;
    --color-primary-hover: #00f5c4;
    --color-secondary: #4a9eff;
    --color-accent: #ff6b9d;
    --color-warning: #ffb84d;
    --color-danger: #ff5757;
    --font-main: 'Noto Sans JP', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.6;
    background-image: 
        radial-gradient(ellipse at 20% 0%, rgba(0, 212, 170, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(74, 158, 255, 0.08) 0%, transparent 50%);
}

/* ========================================
   Container & Layout
======================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Header
======================================== */
.header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.title-icon {
    font-size: 2rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 1.1rem;
}

/* ========================================
   Main Content
======================================== */
.main-content {
    flex: 1;
}

/* ========================================
   Input Section
======================================== */
.input-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.input-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition), box-shadow var(--transition);
}

.input-panel:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.panel-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text);
}

.panel-icon {
    font-size: 1.5rem;
}

/* ========================================
   Form Elements
======================================== */
.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}

.input-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: var(--font-main);
    background: var(--color-surface-elevated);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

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

.input-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.2);
}

/* ========================================
   Buttons
======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-main);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-add {
    width: 100%;
    background: linear-gradient(135deg, var(--color-primary), #00b894);
    color: var(--color-bg);
    margin-bottom: 1.5rem;
}

.btn-add:hover {
    background: linear-gradient(135deg, var(--color-primary-hover), #00d4aa);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 212, 170, 0.4);
}

.btn-add span {
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-secondary), #3d8bff);
    color: white;
    padding: 1rem 2.5rem;
    font-size: 1.125rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(74, 158, 255, 0.4);
}

.btn-secondary {
    background: var(--color-surface-elevated);
    color: var(--color-text);
    border: 2px solid var(--color-border);
    padding: 1rem 2rem;
}

.btn-secondary:hover {
    background: var(--color-border);
    border-color: var(--color-text-muted);
}

.btn-copy {
    background: var(--color-surface-elevated);
    color: var(--color-text);
    border: 2px solid var(--color-border);
}

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

.btn-icon {
    font-size: 1.25rem;
}

/* ========================================
   Lists
======================================== */
.item-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.item-list::-webkit-scrollbar {
    width: 6px;
}

.item-list::-webkit-scrollbar-track {
    background: var(--color-surface);
    border-radius: 3px;
}

.item-list::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.item-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.375rem;
    font-size: 0.95rem;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.item-list li:not(.empty-message) {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.item-list li:not(.empty-message):hover {
    border-color: var(--color-text-muted);
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--color-danger);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1.1rem;
    opacity: 0.6;
    transition: opacity var(--transition), transform var(--transition);
}

.delete-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* ========================================
   Action Section
======================================== */
.action-section {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

/* ========================================
   Result Section
======================================== */
.result-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    display: none;
    animation: fadeIn 0.3s ease;
}

.result-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-primary);
}

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

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-card {
    background: linear-gradient(135deg, var(--color-surface-elevated), var(--color-surface));
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: cardPop 0.3s ease;
    animation-fill-mode: both;
}

@keyframes cardPop {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.result-card:nth-child(1) { animation-delay: 0.05s; }
.result-card:nth-child(2) { animation-delay: 0.1s; }
.result-card:nth-child(3) { animation-delay: 0.15s; }
.result-card:nth-child(4) { animation-delay: 0.2s; }
.result-card:nth-child(5) { animation-delay: 0.25s; }
.result-card:nth-child(6) { animation-delay: 0.3s; }
.result-card:nth-child(7) { animation-delay: 0.35s; }
.result-card:nth-child(8) { animation-delay: 0.4s; }

.result-position {
    background: linear-gradient(135deg, var(--color-primary), #00b894);
    color: var(--color-bg);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-sm);
    min-width: 80px;
    text-align: center;
}

.result-arrow {
    color: var(--color-text-muted);
    font-size: 1.25rem;
}

.result-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--color-text);
}

.result-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

/* ========================================
   Footer
======================================== */
.footer {
    text-align: center;
    padding: 2rem 0 1rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* ========================================
   Toast Notification
======================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--color-surface-elevated);
    color: var(--color-text);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--color-primary);
    transform: translateX(calc(100% + 3rem));
    transition: transform 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    border-left-color: var(--color-danger);
}

.toast.success {
    border-left-color: var(--color-primary);
}

/* ========================================
   Responsive Design
======================================== */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .title {
        font-size: 1.75rem;
    }

    .input-section {
        grid-template-columns: 1fr;
    }

    .action-section {
        flex-direction: column;
    }

    .action-section .btn {
        width: 100%;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.5rem;
    }

    .header {
        margin-bottom: 2rem;
        padding: 1rem 0;
    }

    .input-panel {
        padding: 1rem;
    }

    .result-section {
        padding: 1.25rem;
    }
}
