/* Base Styles */
body {
    background-color: #0a0a0c;
    color: #e2e8f0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
    touch-action: manipulation;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Tool Cards & Containers */
.tool-card {
    background: rgba(22, 22, 26, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
}

.control-panel {
    background: rgba(22, 22, 26, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.tool-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.4s ease-out;
}

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

/* Typography & Colors */
.accent-red { 
    color: #ff3366;
    text-shadow: 0 0 20px rgba(255, 51, 102, 0.4);
}
.accent-cyan { 
    color: #33ccff;
    text-shadow: 0 0 20px rgba(51, 204, 255, 0.4);
}
.accent-yellow { color: #ffcc00; }
.accent-pink { 
    color: #e066ff;
    text-shadow: 0 0 20px rgba(224, 102, 255, 0.4);
}

.label-sin { color: #ff3366; }
.label-cos { color: #33ccff; }
.label-tan { color: #ffcc00; }
.label-angle { color: #e066ff; }
.label-inner { color: #22c55e; }
.label-scheitel { color: #ff9900; }

.branding-title {
    background: linear-gradient(135deg, #f0abfc 0%, #cc33ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(204, 51, 255, 0.3));
    font-weight: 900;
}

.branding-title-cyan {
    background: linear-gradient(135deg, #a5f3fc 0%, #33ccff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(51, 204, 255, 0.3));
    font-weight: 900;
}

/* Inputs & Buttons */
.input-field {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    transition: all 0.2s;
    border-radius: 8px;
    padding: 8px 12px;
}

.input-field:focus {
    border-color: #cc33ff;
    outline: none;
    background: rgba(255, 255, 255, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #cc33ff 0%, #8b5cf6 100%);
    box-shadow: 0 4px 15px rgba(204, 51, 255, 0.3);
    transition: transform 0.2s, opacity 0.2s;
    border-radius: 8px;
}
.btn-primary:hover { transform: translateY(-1px); opacity: 0.9; }

/* Navigation */
.nav-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 20px;
    transition: all 0.3s;
    cursor: pointer;
    opacity: 0.6;
}
.nav-btn:hover { opacity: 1; border-color: #cc33ff; }
.nav-btn.active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    border-color: #cc33ff;
}

/* Toggle Group & Buttons */
.toggle-group {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 10px;
}
.toggle-btn {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    opacity: 0.5;
}
.toggle-btn.active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Header & Footer */
header {
    padding: 2rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 2rem;
}

footer {
    margin-top: auto;
    padding: 2rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
    opacity: 0.6;
    font-size: 0.8rem;
}

/* Canvas & Overlays */
canvas {
    touch-action: none;
    border-radius: 16px;
    background: #111114;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    width: 100% !important;
    height: auto !important;
    max-width: 500px;
}

.angle-display-overlay {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* pH Specific */
.ph-scale {
    height: 40px;
    border-radius: 20px;
    background: linear-gradient(to right, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8f00ff);
    position: relative;
    margin: 20px 0;
}
.ph-indicator {
    position: absolute;
    width: 24px;
    height: 24px;
    background: white;
    border: 3px solid #000;
    border-radius: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Dashboard Specific */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

.dashboard-card {
    transition: transform 0.3s, border-color 0.3s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}
.dashboard-card:hover {
    transform: translateY(-5px);
    border-color: #cc33ff;
}

.search-container {
    margin-bottom: 3rem;
    position: relative;
    width: 100%;
    max-width: 600px;
}
.search-input {
    width: 100%;
    padding: 1.2rem 1.5rem;
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    color: white;
    transition: all 0.3s;
}
.search-input:focus {
    outline: none;
    border-color: #cc33ff;
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 20px rgba(204, 51, 255, 0.1);
}

/* Periodic Table Specific */
.periodic-container {
    display: grid;
    grid-template-columns: repeat(18, minmax(30px, 1fr));
    gap: 4px;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    overflow-x: auto;
}

.element {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    padding: 2px;
}

.element:hover {
    transform: scale(1.1);
    z-index: 10;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.element .atomic-number {
    font-size: 8px;
    position: absolute;
    top: 2px;
    left: 4px;
    opacity: 0.6;
}

.element .symbol {
    font-size: 14px;
    font-weight: 800;
}

.element .mass {
    font-size: 6px;
    opacity: 0.5;
}

/* Category Colors */
.cat-alkali { border-left: 3px solid #ff4444; background: rgba(255, 68, 68, 0.05); }
.cat-alkaline { border-left: 3px solid #ffbb33; background: rgba(255, 187, 51, 0.05); }
.cat-transition { border-left: 3px solid #ff8800; background: rgba(255, 136, 0, 0.05); }
.cat-post-transition { border-left: 3px solid #00c851; background: rgba(0, 200, 81, 0.05); }
.cat-metalloid { border-left: 3px solid #33b5e5; background: rgba(51, 181, 229, 0.05); }
.cat-nonmetal { border-left: 3px solid #0099cc; background: rgba(0, 153, 204, 0.05); }
.cat-noble { border-left: 3px solid #aa66cc; background: rgba(170, 102, 204, 0.05); }
.cat-lanthanide { border-left: 3px solid #ff429c; background: rgba(255, 66, 156, 0.05); }
.cat-actinide { border-left: 3px solid #cc0000; background: rgba(204, 0, 0, 0.05); }

/* Detail Panel */
.element-detail {
    margin-top: 40px;
    padding: 20px;
    width: 100%;
    max-width: 600px;
}
.detail-symbol {
    font-size: 64px;
    font-weight: 900;
}

/* Selection Tray / Cart */
.selection-tray {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: rgba(22, 22, 26, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.selection-tray.minimized {
    transform: translateY(calc(100% - 60px));
}

.tray-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.tray-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
}

.tray-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.tray-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.tray-item .symbol {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-weight: 800;
    font-size: 14px;
}

.tray-btn-remove {
    margin-left: auto;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.tray-btn-remove:hover {
    opacity: 1;
    color: #ff3366;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

.animate-shake {
    animation: shake 0.2s ease-in-out infinite;
}
