@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Symbols+Rounded');

:root {
    --primary: #ff69b4;
    --expense: #6a9bd8;
    --bg-color: #ffffff;
    --text-color: #444;
    --radius: 16px;
}

body {
    margin: 0;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    background-color: #f9f9f9;
    color: var(--text-color);
    padding-bottom: 120px;
    letter-spacing: 0.03em;
    -webkit-tap-highlight-color: transparent;
}

.app-container {
    max-width: 500px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 30px rgba(0,0,0,0.03);
    position: relative;
    z-index: 1;
}

/* Splash Screen */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

#splash-screen.fadeout {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.splash-logo-mask {
    width: 280px;
    height: 90px;
    margin-bottom: 0;
    display: inline-block;
    -webkit-mask-image: url('../static/logo.svg');
    mask-image: url('../static/logo.svg');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    background-color: var(--primary);
    animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fade-up {
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.app-header {
    background: var(--primary);
    color: var(--text-on-primary);
    padding: 30px 20px 20px;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.oshi-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: white;
    object-fit: cover;
    border: 3px solid rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.oshi-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Common Components */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    margin: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.04);
    border: 1px solid #f0f0f0;
}

input, select, textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid #eee;
    border-radius: 12px;
    background: #fafafa;
    font-size: 1rem;
    font-family: inherit;
    box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

button.submit-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: var(--text-on-primary);
    border: none;
    border-radius: 50px;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.3s;
}

button.submit-btn:active {
    transform: scale(0.98);
}

.file-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: #f0f0f0;
    color: #666;
    border-radius: 30px;
    font-size: 0.9rem;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    border: 1px dashed #ccc;
    margin-top: 5px;
}

.file-upload-label.active {
    border-color: var(--primary);
    color: var(--primary);
    background: #fff0f5;
}

input[type="file"] {
    display: none;
}

.yt-preview {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 12px;
    margin-top: 10px;
    display: none;
    object-fit: cover;
}

/* Gauge */
.gauge-container {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 10px auto;
}

.gauge-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    overflow: visible;
}

.gauge-bg {
    fill: none;
    stroke: #eee;
    stroke-width: 18;
}

.gauge-bar {
    fill: none;
    stroke-width: 18;
    stroke-linecap: round;
    stroke-dasharray: 377;
    stroke-dashoffset: 377;
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 100%;
}

.gauge-percent {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.gauge-label {
    font-size: 0.8rem;
    color: #888;
    margin-top: 5px;
}

/* Switch UI */
.type-switch {
    display: flex;
    background: #f0f0f0;
    border-radius: 50px;
    padding: 5px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.05);
}

.type-opt {
    flex: 1;
    text-align: center;
    padding: 12px 5px;
    border-radius: 40px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
    color: #aaa;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.type-opt.active {
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.type-opt.active[data-type="income"] {
    color: var(--primary);
}

.type-opt.active[data-type="expense"] {
    color: var(--expense);
}

/* Calendar & Days */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
    padding: 0 15px;
}

.cal-day {
    aspect-ratio: 0.75;
    border-radius: 8px;
    background: #f7f7f7;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    font-size: 0.8rem;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    padding-top: 4px;
    border: 1px solid transparent;
}

.cal-day.today {
    border-color: var(--primary);
    background: #fff5f9;
    color: var(--primary);
    font-weight: bold;
}

.cal-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.5;
    z-index: 1;
}

.cal-day span {
    position: relative;
    z-index: 2;
}

.daily-total {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 0.6rem;
    background: rgba(255,255,255,0.9);
    padding: 1px 3px;
    border-radius: 4px;
    color: #333;
    font-weight: bold;
    z-index: 3;
    pointer-events: none;
}

.dt-plus {
    color: var(--primary);
}

.dt-minus {
    color: var(--expense);
}

/* Detail List */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.add-circle-btn {
    background: var(--primary);
    color: var(--text-on-primary);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 0;
}

.add-circle-btn .material-symbols-rounded {
    font-size: 20px;
}

.log-item {
    display: block;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #eee;
}

.log-thumb {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: #eee;
    object-fit: cover;
    flex-shrink: 0;
}

.log-info {
    flex: 1;
    min-width: 0;
}

.log-title {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-meta {
    font-size: 0.75rem;
    color: #888;
    display: flex;
    gap: 5px;
}

.type-badge {
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.65rem;
    color: white;
}

.bg-inc {
    background: var(--primary);
}

.bg-exp {
    background: var(--expense);
}

.log-price {
    font-weight: bold;
    font-size: 0.9rem;
    margin-top: 2px;
}

.txt-inc {
    color: var(--primary);
}

.txt-exp {
    color: var(--expense);
}

/* Report & Month Selector */
.month-selector {
    display: flex;
    gap: 10px;
    padding: 10px 20px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.month-selector::-webkit-scrollbar {
    display: none;
}

.month-chip {
    padding: 8px 16px;
    border-radius: 20px;
    background: #eee;
    color: #888;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.month-chip.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.report-month-box {
    background: white;
    border-radius: 16px;
    margin: 15px 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    overflow: hidden;
    border: 1px solid #eee;
}

.report-content {
    padding: 15px;
}

.report-balance-box {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    background: white;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 15px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    border: 1px solid #f9f9f9;
}

.rb-item {
    padding: 0 5px;
}

.rb-label {
    font-size: 0.7rem;
    color: #aaa;
    margin-bottom: 2px;
}

.rb-val {
    font-weight: bold;
    font-size: 0.9rem;
}

.report-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 10px;
    border-radius: 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.report-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-icon-btn {
    background: #f8f8f8;
    border: none;
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modals */
dialog {
    border: none;
    border-radius: 20px;
    padding: 20px;
    width: 85%;
    max-width: 350px;
    max-height: 80vh;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    box-sizing: border-box;
    overflow-x: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 10000;
}

dialog::backdrop {
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    z-index: 9999;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(10px);
    border-top: 1px solid #eee;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 9999;
    display: flex;
    justify-content: space-around;
}

.nav-item {
    padding: 10px 0;
    flex: 1;
    text-align: center;
    color: #aaa;
    font-size: 0.65rem;
    cursor: pointer;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    display: block;
    margin-bottom: 4px;
    font-size: 24px;
}

.material-symbols-rounded {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.nav-item.active .material-symbols-rounded {
    font-variation-settings: 'FILL' 1;
}

.tab-content {
    display: none;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
    padding-bottom: 50px;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* Category Edit */
.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.category-box {
    aspect-ratio: 1;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    padding: 5px;
    min-width: 0;
}

.cat-icon {
    font-size: 28px;
    margin-bottom: 5px;
    color: var(--primary);
}

.category-box.empty {
    border: 1px dashed #ccc;
    background: #fdfdfd;
    color: #ccc;
}

.icon-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 15px;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 12px;
}

.icon-option {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    background: white;
    color: #888;
}

.icon-option.selected {
    border-color: var(--primary);
    color: var(--primary);
    background: #fff0f5;
}

/* Sub Tabs (Home) */
.sub-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding: 20px 20px;
}

.sub-tab-item {
    padding: 8px 16px;
    border-radius: 20px;
    background: #eee;
    color: #888;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.sub-tab-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* FAB */
.fab-btn {
    position: fixed;
    bottom: 85px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.2s;
}

.fab-btn:active {
    transform: scale(0.9);
}

.fab-btn span {
    font-size: 32px;
}

/* Unwatched List Item */
.unwatched-item {
    background: white;
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    border: 1px solid #eee;
    position: relative;
}

.unwatched-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #ff4757;
    color: white;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    z-index: 2;
}

.video-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.action-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: none;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-play {
    background: #f0f0f0;
    color: #444;
}

.btn-record {
    background: var(--primary);
    color: white;
}

/* Timestamp Link */
.ts-link {
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: bold;
}

/* Search Box */
.search-box {
    display: flex;
    align-items: stretch;
    border: 1px solid #eee;
    border-radius: 12px;
    background: #fafafa;
    overflow: hidden;
    margin-top: 15px;
}

.search-box input#search-input {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
}

.search-box input#search-input:focus {
    background: white;
    outline: none;
}

.search-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 15px;
    cursor: pointer;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.search-btn:hover {
    opacity: 0.9;
}

.search-btn .material-symbols-rounded {
    font-size: 24px;
    font-variation-settings: 'wght' 600;
}

/* Latest Videos */
.latest-scroll-area {
    display: flex;
    overflow-x: auto;
    padding: 0 20px 20px;
    gap: 15px;
    scrollbar-width: none;
}

.latest-scroll-area::-webkit-scrollbar {
    display: none;
}

.latest-video-card {
    min-width: 140px;
    width: 140px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.2s;
}

.latest-video-card:active {
    transform: scale(0.95);
}

.latest-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: #000;
}

.latest-info {
    padding: 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.latest-title {
    font-size: 0.75rem;
    font-weight: bold;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    margin-bottom: 5px;
}

.latest-date {
    font-size: 0.65rem;
    color: #999;
}

/* Paste Button */
.paste-btn {
    padding: 0 15px;
    border-radius: 12px;
    border: 1px solid #eee;
    background: #f0f0f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.paste-btn:active {
    background: #e0e0e0;
}

.paste-btn .material-symbols-rounded {
    color: inherit;
}