:root {
    --bg-color: #0b0d12;
    --card-bg: #161922;
    --text-primary: #ffffff;
    --text-secondary: #8b9bb4;
    --accent: #dcdcdc;
    --accent-glow: rgba(255, 255, 255, 0.15);
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --safe-area-top: env(safe-area-inset-top, 20px);
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
header {
    padding: calc(15px + var(--safe-area-top)) 20px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 100;
}

.location-display {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    text-align: left;
    font-weight: 600;
    padding: 0;
    cursor: pointer;
}

.location-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.settings-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
}

/* --- Main --- */
main {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

.view {
    display: none;
    padding: 30px 20px calc(80px + var(--safe-area-bottom));
    min-height: 100%;
    flex-direction: column;
    align-items: center;
}

.view.active {
    display: flex;
}

/* --- Moon Visual --- */
.moon-container {
    width: 220px;
    height: 220px;
    margin: 20px 0;
    position: relative;
    filter: drop-shadow(0 0 20px var(--accent-glow));
}

#moon-svg {
    width: 100%;
    height: 100%;
    fill: var(--card-bg);
}

#moon-path {
    fill: var(--accent);
    transition: d 0.5s ease-out;
}

/* --- Info --- */
.phase-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
    text-align: center;
}

.illumination {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 30px;
    text-align: center;
}

/* --- Progress Bar --- */
.cycle-container {
    width: 100%;
    max-width: 320px;
    margin-bottom: 30px;
    text-align: center;
}

.cycle-labels {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-bottom: 8px;
    opacity: 0.8;
}

.progress-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.5s ease;
    position: relative;
}

.progress-marker {
    position: absolute;
    top: -4px;
    left: 0%;
    width: 2px;
    height: 14px;
    background: #fff;
    transform: translateX(-50%);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

/* --- Cards --- */
.cards-grid {
    width: 100%;
    max-width: 400px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    justify-items: stretch;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}

.card-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-value {
    font-size: 1.1rem;
    font-weight: 500;
}

.countdown-value {
    color: var(--accent);
    font-weight: 600;
}

/* --- Detail Rows --- */
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    width: 100%;
    max-width: 400px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-secondary);
}

.detail-data {
    font-weight: 500;
    text-align: right;
}

/* --- List --- */
.phase-list {
    width: 100%;
    max-width: 400px;
    margin-top: 20px;
}

.phase-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.phase-icon {
    width: 30px;
    height: 30px;
    margin-right: 15px;
    background: var(--card-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.phase-info {
    flex: 1;
}

.phase-date {
    font-weight: 600;
    font-size: 0.9rem;
}

.phase-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* --- Settings Inputs --- */
.settings-group {
    width: 100%;
    max-width: 400px;
    margin-bottom: 25px;
}

.settings-title {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 5px;
}

.text-input {
    width: 100%;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    outline: none;
}

.text-input:focus {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.08);
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch.on {
    background: var(--accent);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-switch.on::after {
    transform: translateX(20px);
}

.btn-action {
    width: 100%;
    max-width: 400px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    border-radius: 12px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-action:active {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Widget Preview --- */
.widget-preview {
    background: #000;
    border-radius: 20px;
    padding: 20px;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    border: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.widget-moon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #333;
    overflow: hidden;
}

.widget-info {
    text-align: right;
}

.widget-info div {
    font-size: 0.7rem;
    color: #888;
}

.widget-info strong {
    display: block;
    font-size: 1rem;
}

/* --- Nav --- */
nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(11, 13, 18, 0.9);
    backdrop-filter: blur(10px);
    padding: 10px 0 calc(10px + var(--safe-area-bottom));
    display: flex;
    justify-content: space-around;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 20;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    width: 60px;
}

.nav-item.active {
    color: var(--accent);
}

.nav-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
}