:root {
    /* New Royal Violet palette */
    --primary: #D56842;        /* Soft Orange (CTA) */
    --primary-dark: #bf5d3b;   
    --secondary: #E4A200;      /* Honey Gold (headers/rooms) */
    --charcoal: #48414A;       /* Charcoal Gray (secondary/details/text) */
    --background: #66539A;     /* Royal Violet (page background) */
    --surface: #ffffff;        /* light surfaces on violet bg */
    --surface-light: #f6f4fa;  /* very light surface */
    --text: #48414A;           /* primary text high-contrast */
    --text-secondary: #3A3432; /* secondary text */
    --success: #24A83B;        /* success */
    --warning: #E4A200;        /* mild warn highlight */
    --danger: #ef4444;
    --border-radius: 14px;     /* rounded 14px */
    --shadow: 0 6px 12px rgba(0,0,0,0.12); /* soft shadow */
    --transition: all 0.2s ease;
}

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

html, body {
    overflow-x: hidden;
}

body {
    font-family: 'Poppins', 'Inter', 'Nunito', 'Rubik', 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #5C3F9B;
    background-image: 
        radial-gradient(ellipse 80% 50% at 15% 25%, rgba(155, 76, 163, 0.6) 0%, transparent 70%),
        radial-gradient(ellipse 70% 40% at 85% 15%, rgba(204, 90, 163, 0.5) 0%, transparent 65%),
        radial-gradient(ellipse 60% 45% at 75% 75%, rgba(246, 115, 146, 0.5) 0%, transparent 60%),
        radial-gradient(ellipse 50% 35% at 25% 80%, rgba(254, 175, 13, 0.25) 0%, transparent 55%),
        radial-gradient(ellipse 55% 40% at 50% 50%, rgba(155, 76, 163, 0.3) 0%, transparent 60%),
        radial-gradient(ellipse 45% 30% at 10% 60%, rgba(92, 63, 155, 0.4) 0%, transparent 50%);
    background-size: 200% 200%;
    background-attachment: fixed;
    animation: meshGradient 20s ease-in-out infinite;
    color: var(--text);
    line-height: 1.6;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: -1;
}

@keyframes meshGradient {
    0%, 100% {
        background-position: 0% 50%, 100% 50%, 50% 100%, 0% 100%, 50% 0%, 100% 0%;
    }
    25% {
        background-position: 25% 25%, 75% 25%, 75% 75%, 25% 75%, 50% 50%, 0% 50%;
    }
    50% {
        background-position: 50% 0%, 100% 0%, 100% 100%, 0% 100%, 50% 50%, 50% 100%;
    }
    75% {
        background-position: 75% 25%, 25% 25%, 25% 75%, 75% 75%, 50% 50%, 100% 50%;
    }
}

.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #5C3F9B;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

.splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.splash-logo {
    width: 150px;
    height: 150px;
    animation: logoFadeIn 1s ease-out forwards;
    opacity: 0;
}

.splash-title {
    color: #ffffff;
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 20px;
    text-align: center;
    animation: titleFadeIn 1s ease-out 0.5s forwards;
    opacity: 0;
}

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

@keyframes logoFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.splash-screen.fade-out {
    animation: splashFadeOut 0.5s ease-out forwards;
}

@keyframes splashFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.container { max-width: 720px; margin: 0 auto; padding: 12px 16px; min-height: 100vh; display: flex; flex-direction: column; }

header { 
  position: fixed; 
  top: 0; 
  left: 0;
  right: 0;
  z-index: 1000; 
  background: var(--background); 
  padding: 12px 16px env(safe-area-inset-top) env(safe-area-inset-left);
}

main { padding-top: 300px; }

h1 { font-size: 1.5rem; text-align: center; margin-bottom: 8px; color: #ffffff; font-weight: 600; }

/* Dropdown menu items hover effect */
.dropdown-item:hover { background: #f5f5f5; }

/* Readability on violet background */
header, header a { color: #ffffff; }
footer small { color: #ffffff; }
/* Tabs styling: inactive = Honey Gold buttons, active = primary with white text */
.top-actions .btn-ghost { background: var(--secondary); border-color: var(--secondary); color: #ffffff !important; }
.top-actions .btn-ghost.active { background: var(--primary); border-color: var(--primary); color: #ffffff !important; }
/* Placeholder color for inputs */
input::placeholder, textarea::placeholder { color: #D9D9D9; opacity: 1; }

.dashboard { background: var(--surface); border-radius: var(--border-radius); padding: 16px; box-shadow: var(--shadow); }

.dashboard-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }

.stat-card { background: var(--surface-light); border-radius: 12px; padding: 10px; text-align: center; }
.stat-card h3 { font-size: .9rem; color: var(--text-secondary); margin-bottom: 6px; }
.stat-card .value { font-weight: 700; font-size: 1.4rem; }

.status { text-align: center; margin-top: 8px; font-weight: 600; }

.task-filters { display: flex; gap: 12px; margin: 16px 0; flex-wrap: wrap; }
.search-input, .section-filter { flex: 1 1 100%; padding: 14px 16px; border: 1px solid #ddd7ee; border-radius: 14px; background: #ffffff; color: var(--text); min-height: 46px; }
.section-filter { max-width: none; }

.section { margin-bottom: 18px; }
.section h2 { font-size: 1.1rem; margin-bottom: 10px; padding: 10px 12px; background: var(--secondary); color: #ffffff; border-radius: 12px; font-weight: 600; }

/* Setup view: headings should be white over gold header */
#view-setup h2 { color: #ffffff; }

.task-card { background: var(--surface); border-radius: var(--border-radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); animation: fadeIn .25s ease-out; }
.task-header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.task-name { font-weight: 700; font-size: 1.05rem; }
.task-when { font-size: .9rem; color: var(--text-secondary); margin-top: 2px; }

.task-points { display: flex; gap: 8px; margin-top: 8px; }
.point-input { flex: 1; display: flex; flex-direction: column; align-items: center; }
.point-input label { font-size: .8rem; color: var(--text-secondary); margin-bottom: 4px; }
.point-input input { width: 100%; padding: 10px; text-align: center; border: 1px solid #ddd7ee; border-radius: 12px; background: #ffffff; color: var(--text); }

.task-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.btn { padding: 12px 16px; border: 0; border-radius: var(--border-radius); background: var(--primary); color: #fff; font-weight: 700; cursor: pointer; transition: var(--transition); min-height: 46px; letter-spacing: .2px; }
.btn:hover { opacity: 0.95; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-mada { background: #8b5cf6; }
.btn-flavio { background: #3b82f6; }
.btn-logs { background: var(--surface-light); color: var(--text); }
.btn-warning { background: var(--warning); color: #1D1412; }
.btn-danger { background: #E84448; color: #ffffff; }

/* Top actions / tabs */
.top-actions { position: sticky; top: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding-bottom: 8px; background: transparent; }
.btn-ghost { background: #ffffff; border: 1px solid var(--charcoal); color: var(--charcoal); }
.btn-ghost.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); color: #fff; background: var(--primary); }

.logs-chip { display: inline-flex; align-items: center; background: var(--surface-light); border-radius: 16px; padding: 6px 12px; margin: 3px; font-size: .85rem; color: var(--text); }
.logs-chip .delete { margin-left: 6px; color: var(--danger); cursor: pointer; }

.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 1000; justify-content: center; align-items: flex-start; padding: 24px 12px; overflow-y: auto; }
.modal-content { width: 100%; max-width: 520px; background: var(--surface); border-radius: var(--border-radius); padding: 16px; box-shadow: var(--shadow); position: relative; }
.modal h2 { color: var(--text); margin-bottom: 12px; font-weight: 600; }
.close { position: absolute; right: 14px; top: 10px; font-size: 1.6rem; color: var(--text-secondary); cursor: pointer; }
.close:hover { color: var(--text); }

#logsList { max-height: 420px; overflow-y: auto; margin-bottom: 12px; }
.log-entry { background: var(--surface-light); border-radius: var(--border-radius); padding: 12px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.log-info { flex: 1; }
.log-date { font-size: .9rem; color: var(--text-secondary); }
.log-note { margin-top: 4px; font-size: .92rem; }
.delete-log { margin-left: 10px; color: var(--danger); cursor: pointer; }

.btn-group { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.btn-group .btn { width: 100%; }

#noteInput, #importText { width: 100%; min-height: 120px; padding: 10px; border-radius: 10px; border: 1px solid #e5e7eb; background: #ffffff; color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

footer { margin-top: auto; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
footer .btn { flex: 1; }

.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-secondary); }

@media (min-width: 768px) {
  .dashboard-stats { grid-template-columns: repeat(4, 1fr); }
  .btn-group { flex-direction: row; flex-wrap: wrap; }
  .btn-group .btn { flex: 1 1 calc(50% - 8px); }
}

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

@media (display-mode: standalone) { body { padding-bottom: 64px; } }

/* New components for refactored app */
.top-actions { display: flex; gap: 8px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.btn-ghost { background: transparent; border: 1px solid #26324a; color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,0.04); }

.view { display: block; }
.hidden { display: none !important; }

.card { background: rgba(255, 255, 255, 0.5); border-radius: var(--border-radius); padding: 16px; box-shadow: var(--shadow); margin: 12px 0; backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.3); }

.pill-list { list-style: none; display: flex; gap: 8px; flex-wrap: wrap; }

.ratings-matrix { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ratings-matrix table { width: 100%; border-collapse: collapse; }
.ratings-matrix th, .ratings-matrix td { border: 1px solid #e5e7eb; padding: 10px; text-align: center; }
.ratings-matrix thead th { background: var(--surface); color: var(--text-secondary); position: sticky; top: 0; z-index: 1; }
.ratings-matrix select { width: 100%; padding: 6px; border-radius: 8px; border: 1px solid #e5e7eb; background: #ffffff; color: var(--text); }

.chore-table { display: grid; grid-template-columns: 1fr; gap: 12px; }
.chore-table .btn { flex: 1 1 calc(50% - 8px); }

.btn.btn-danger { background: #E84448; color: #ffffff; border-color: #E84448; }
.btn.btn-warning { background: var(--warning); color: #111; }

/* Accordion rooms in dashboard */
.room-accordion { background: var(--surface); border: 1px solid #e5e7eb; border-radius: var(--border-radius); box-shadow: var(--shadow); overflow: hidden; }
.room-header { width: 100%; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; background: var(--secondary); color: #ffffff; border: 0; cursor: pointer; font-weight: 600; }
.room-header .chevron { transition: transform .2s ease; }
.room-header[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.room-content { padding: 8px 8px 12px; }
