:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a2332;
    --bg-card: #232f3e;
    --accent-primary: #ff6b35;
    --accent-secondary: #f7931e;
    --accent-gradient: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    --text-primary: #ffffff;
    --text-secondary: #8899a6;
    --text-muted: #5c6b7a;
    --border-color: #2f3d4d;
    --success: #17bf63;
    --tile-color-1: #d4a373;
    --tile-color-2: #ccd5ae;
    --tile-border: #a98467;
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(255, 107, 53, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    background-image: 
        radial-gradient(ellipse at 20% 20%, rgba(255, 107, 53, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(247, 147, 30, 0.06) 0%, transparent 50%),
        linear-gradient(180deg, var(--bg-primary) 0%, #0a0e13 100%);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 40px 0 50px;
    position: relative;
    margin-bottom: 50px;
}

header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 3px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

h1 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
}

.main-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 1100px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 28px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.panel-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-title::before {
    content: '';
    width: 4px;
    height: 24px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

.form-section {
    margin-bottom: 28px;
}

.form-section:last-child {
    margin-bottom: 0;
}

.section-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
    font-weight: 500;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-group {
    position: relative;
}

.input-group label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 50px 14px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
    transition: all 0.3s ease;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.15);
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-unit {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.pattern-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.pattern-btn {
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    min-width: 0;
}

.pattern-btn:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.pattern-btn.active {
    border-color: var(--accent-primary);
    background: rgba(255, 107, 53, 0.1);
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.2);
}

.pattern-icon {
    width: 36px;
    height: 36px;
    display: grid;
    gap: 2px;
}

.pattern-icon.grid-pattern {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.pattern-icon.brick-pattern {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 36px;
    height: 32px;
    overflow: hidden;
}

.pattern-icon.brick-pattern .row {
    display: flex;
    gap: 2px;
    height: 9px;
    flex-shrink: 0;
}

.pattern-icon.brick-pattern .row:nth-child(1) {
    margin-left: -8px;
}

.pattern-icon.brick-pattern .row:nth-child(2) {
    margin-left: 0;
}

.pattern-icon.brick-pattern .row:nth-child(3) {
    margin-left: -8px;
}

.pattern-icon.brick-pattern .tile {
    width: 16px;
    height: 9px;
    background: var(--tile-color-1);
    border-radius: 2px;
    flex-shrink: 0;
}

.pattern-icon.brick-pattern .row:nth-child(2) .tile {
    background: var(--tile-color-2);
}

.pattern-icon.diagonal-pattern {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    transform: rotate(45deg) scale(0.7);
}

.pattern-icon.third-pattern {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 36px;
    height: 32px;
    overflow: hidden;
}

.pattern-icon.third-pattern .row {
    display: flex;
    gap: 2px;
    height: 9px;
}

.pattern-icon.third-pattern .row:nth-child(1) {
    margin-left: -5px;
}

.pattern-icon.third-pattern .row:nth-child(2) {
    margin-left: 0;
}

.pattern-icon.third-pattern .row:nth-child(3) {
    margin-left: 5px;
}

.pattern-icon.third-pattern .tile {
    width: 16px;
    height: 9px;
    background: var(--tile-color-1);
    border-radius: 2px;
}

.pattern-icon.third-pattern .row:nth-child(2) .tile {
    background: var(--tile-color-2);
}

.pattern-icon span {
    background: var(--tile-color-1);
    border-radius: 2px;
}

.pattern-icon span:nth-child(even) {
    background: var(--tile-color-2);
}



.pattern-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

.color-picker-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-picker-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.color-picker {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: none;
    padding: 0;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: 2px solid var(--border-color);
    border-radius: 8px;
}

.calculate-btn {
    width: 100%;
    padding: 16px 24px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 24px;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.4);
}

.calculate-btn:active {
    transform: translateY(0);
}

.visualization-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.canvas-container {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.canvas-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent-gradient);
}

#tileCanvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    background: #2a3444;
}

/* Canvas action buttons */
.canvas-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    justify-content: center;
}

.canvas-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: 'Montserrat', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.canvas-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: rgba(255, 107, 53, 0.1);
}

.canvas-btn.primary {
    background: var(--accent-gradient);
    border: none;
    color: white;
}

.canvas-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.canvas-btn svg {
    width: 18px;
    height: 18px;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.modal-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

#tileCanvasHD {
    max-width: 100%;
    max-height: calc(95vh - 100px);
    border-radius: 12px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.result-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border-color);
    text-align: center;
    transition: all 0.3s ease;
}

.result-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
    border-color: var(--accent-primary);
}

.result-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    background: var(--accent-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.result-icon svg {
    width: 24px;
    height: 24px;
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-family: 'Montserrat', sans-serif;
}

.result-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-sublabel {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.dimensions-display {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 16px;
    background: rgba(255, 107, 53, 0.05);
    border-radius: 12px;
    margin-bottom: 16px;
}

.dimension-item {
    text-align: center;
}

.dimension-value {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.dimension-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.waste-warning {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(255, 107, 53, 0.1);
    border: 1px solid rgba(255, 107, 53, 0.3);
    border-radius: 12px;
    margin-top: 16px;
}

.waste-warning-icon {
    font-size: 1.5rem;
}

.waste-warning-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.waste-warning-text strong {
    color: var(--accent-primary);
}

.preset-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.preset-btn {
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Montserrat', sans-serif;
}

.preset-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel, .result-card {
    animation: fadeInUp 0.5s ease forwards;
}

.result-card:nth-child(1) { animation-delay: 0.1s; }
.result-card:nth-child(2) { animation-delay: 0.15s; }
.result-card:nth-child(3) { animation-delay: 0.2s; }
.result-card:nth-child(4) { animation-delay: 0.25s; }
.result-card:nth-child(5) { animation-delay: 0.3s; }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.grout-input {
    margin-top: 16px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.checkbox-group label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
}

/* Start point selector */
.start-point-container {
    display: flex;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
}

.start-point-selector-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.start-point-selector {
    display: grid;
    grid-template-columns: repeat(3, 28px);
    grid-template-rows: repeat(3, 28px);
    gap: 4px;
}

.start-point-btn {
    width: 28px;
    height: 28px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.start-point-btn:hover {
    border-color: var(--accent-primary);
    background: rgba(255, 107, 53, 0.1);
}

.start-point-btn.active {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
}

.start-point-btn.active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.start-point-name {
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-weight: 500;
    white-space: nowrap;
}


.offset-inputs {
    margin-top: 16px;
}

.offset-inputs .input-row {
    gap: 12px;
}

.offset-inputs .input-wrapper input {
    padding: 10px 45px 10px 12px;
    font-size: 0.9rem;
}

.offset-hint, .input-hint {
    margin-top: 10px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.input-hint {
    margin-top: 6px;
}

.checkbox-group.custom-offset {
    margin-top: 12px;
    margin-bottom: 12px;
}

/* Cut sizes panel */
.cut-sizes-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
    border: 1px solid var(--border-color);
}

.cut-sizes-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    font-weight: 500;
}

.cut-sizes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.cut-size-item {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.cut-size-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.cut-size-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.cut-size-value.full {
    color: var(--success);
}

.optimization-tip {
    margin-top: 16px;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.15), rgba(76, 175, 80, 0.05));
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.tip-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.tip-content {
    flex: 1;
}

.tip-title {
    font-weight: 600;
    color: #4caf50;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.tip-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.tip-text strong {
    color: var(--text-primary);
}

/* SEO Article */
.seo-article {
    margin-top: 40px;
    padding: 40px;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.seo-article h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    position: relative;
    padding-left: 20px;
}

.seo-article h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

.seo-article h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin: 28px 0 16px;
}

.seo-article p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.seo-article ul {
    list-style: none;
    margin: 16px 0 24px;
    padding: 0;
}

.seo-article ul li {
    position: relative;
    padding-left: 24px;
    margin-bottom: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
}

.seo-article ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 8px;
    height: 8px;
    background: var(--accent-gradient);
    border-radius: 50%;
}

.seo-article strong {
    color: var(--text-primary);
    font-weight: 600;
}

.seo-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin: 24px 0;
}

.seo-feature {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.seo-feature-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.seo-feature h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.seo-feature p {
    margin-bottom: 0;
    font-size: 0.9rem;
}

