@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght=0,400;0,600;0,700;1,400&family=DM+Sans:wght=300;400;500;700&display=swap');

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

body {
    background: #fafafa;
    font-family: 'DM Sans', sans-serif;
    color: #1a1a1a;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 16px;
    letter-spacing: -0.01em;
    transition: padding 0.3s ease;
}

.app-wrapper {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    transition: max-width 0.3s ease;
}

.header {
    text-align: center;
}

.header a {
    text-decoration: none;
    color: inherit;
}

h1 {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 2.2rem;
    color: #000000;
    font-weight: 600;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 0.85rem;
    color: #777777;
    font-weight: 400;
}

.app-layout {
    display: flex;
    flex-direction: column;
    gap: 28px;
    width: 100%;
}

.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 20px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 12px;
    width: 100%;
}

.mode-btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    border: none;
    background: none;
    color: #777777;
    cursor: pointer;
    padding: 4px 0;
    position: relative;
    transition: color 0.25s;
}

.mode-btn.active {
    color: #000000;
    font-weight: 700;
}

.mode-btn.active::after {
    content: '';
    position: absolute;
    bottom: -13px;
    left: 0;
    right: 0;
    height: 2px;
    background: #000000;
}

.control-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.unit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.unit-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #777777;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.unit-select {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 4px 12px;
    border: none;
    background: transparent;
    color: #000000;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23777777' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0 center;
    padding-right: 18px;
    text-align: right;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-label-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: #777777;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.input-wrapper {
    display: flex;
    align-items: center;
    border-bottom: 2px solid #000000;
    padding-bottom: 4px;
    width: 100%;
}

input[type="number"] {
    font-family: 'DM Sans', sans-serif;
    font-size: 1.15rem;
    font-weight: 500;
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    color: #000000;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
}

button.calc-btn {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    color: #777777;
    background: none;
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    transition: color 0.2s;
}

button.calc-btn:hover { 
    color: #000000; 
}

.toggle-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    cursor: pointer;
    user-select: none;
    align-self: flex-start;
}

.toggle-checkbox {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid #000000;
    border-radius: 3px;
    background: transparent;
    outline: none;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
}

.toggle-checkbox:checked {
    background: #000000;
}

.toggle-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fafafa;
    font-size: 9px;
    font-weight: bold;
}

.toggle-text {
    font-size: 0.72rem;
    font-weight: 500;
    color: #777777;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hasil-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    text-align: center;
}

.hasil-teks {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 1.2rem;
    color: #000000;
    min-height: 28px;
    background: transparent;
    padding: 0;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.25s, transform 0.25s;
}

.hasil-teks.visible {
    opacity: 1;
    transform: translateY(0);
}

.hasil-tumpuk {
    font-size: 0.8rem;
    color: #777777;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.25s 0.05s, transform 0.25s 0.05s;
}

.hasil-tumpuk.visible {
    opacity: 1;
    transform: translateY(0);
}

.hasil-tumpuk strong {
    color: #000000;
    font-weight: 700;
}

.chart-wrap {
    position: relative;
    width: 100%;
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chart-inner {
    display: flex;
    flex-direction: row;
    position: relative;
    height: 280px;
    background: transparent;
}

.ruler {
    width: 48px;
    flex-shrink: 0;
    position: relative;
    height: 100%;
    border-right: 1px solid #e0e0e0;
}

.ruler-tick {
    position: absolute;
    left: 0;
    width: 48px;
    display: flex;
    align-items: center;
    transform: translateY(50%);
}

.ruler-tick span {
    font-size: 0.62rem;
    color: #777777;
    padding-left: 4px;
    white-space: nowrap;
}

.ruler-tick::after {
    content: '';
    position: absolute;
    right: 0;
    width: 5px;
    height: 1px;
    background: #b0b0b0;
}

.figure-area {
    flex: 1;
    position: relative;
    height: 100%;
}

.grid-line {
    position: absolute;
    left: 0; right: 0;
    height: 1px;
    background: rgba(0, 0, 0, 0.04);
}

.input-line {
    position: absolute;
    left: 0; right: 0;
    border-top: 1.5px dashed #000000;
    pointer-events: none;
    z-index: 4;
}

.figure-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column-reverse; 
    align-items: center;
    justify-content: flex-start;
    pointer-events: none;
    margin: 0;
    padding: 0;
}

.fig-top-label {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 500;
    color: #000000;
    text-align: center;
    white-space: nowrap;
    background: #fafafa;
    padding: 1px 6px;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    z-index: 5;
}

.figure-img {
    display: block;
    object-fit: contain;
    object-position: bottom center;
    transition: height 0.35s cubic-bezier(0.4,0,0.2,1);
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.figure-stack-div {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.floor {
    height: 30px;
    background: transparent;
    border-top: 2px solid #000000;
    display: flex;
    align-items: center;
    padding-left: 56px;
    flex-shrink: 0;
}

.floor-label {
    font-size: 0.65rem;
    color: #777777;
}

.tables-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    border-top: 1px solid #e0e0e0;
    padding-top: 24px;
    margin-top: 8px;
}

.table-section {
    width: 100%;
}

.table-title {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 1rem;
    color: #000000;
    margin-bottom: 8px;
}

.conversion-table {
    width: 100%;
    font-size: 0.78rem;
    border-collapse: collapse;
    color: #555555;
}

.conversion-table td {
    padding: 5px 0;
    border-bottom: 1px solid #f0f0f0;
}

.conversion-table td:last-child {
    color: #000000;
    font-weight: 500;
    text-align: right;
}

.conversion-table tr:last-child td {
    border-bottom: none;
}

.empty-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.78rem;
    color: #777777;
    font-style: italic;
    text-align: center;
    width: 100%;
    pointer-events: none;
}

@media (min-width: 768px) {
    body {
        padding: 80px 32px;
    }

    .app-wrapper {
        max-width: 820px;
    }

    .header {
        text-align: left;
        border-bottom: 1px solid #e0e0e0;
        padding-bottom: 16px;
        margin-bottom: 12px;
    }

    .app-layout {
        display: grid;
        grid-template-columns: 1.1fr 0.9fr;
        grid-template-rows: auto auto auto 1fr;
        gap: 28px 48px;
        align-items: start;
    }

    .mode-toggle {
        grid-column: 1;
        grid-row: 1;
    }

    .control-panel {
        grid-column: 1;
        grid-row: 2;
    }

    .hasil-wrap {
        grid-column: 1;
        grid-row: 3;
    }

    .tables-grid {
        grid-column: 1;
        grid-row: 4;
        margin-top: 0;
        border-top: 1px solid #e0e0e0;
        padding-top: 24px;
    }

    .visual-panel {
        grid-column: 2;
        grid-row: 1 / span 4;
        position: sticky;
        top: 40px;
        z-index: 10;
    }
}