:root {
    --primary-color: #007AFF;
    --background-gradient: linear-gradient(135deg, #f0f2ff 0%, #e8eaff 40%, #f3eeff 100%);
    --card-background: rgba(255, 255, 255, 0.72);
    --card-border: 1px solid rgba(255, 255, 255, 0.5);
    --text-color: #1c1c1e;
    --secondary-text: #8e8e93;
    --separator-color: rgba(60, 60, 67, 0.12);
    --yukiko-color: #FF2D55;
    --takuya-color: #5856D6;
    --safe-area-bottom: env(safe-area-inset-bottom);
    --shadow-soft: 0 8px 32px 0 rgba(88, 86, 214, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--background-gradient);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.content {
    flex: 1;
    overflow: hidden;
    position: relative;
    padding-top: max(1rem, env(safe-area-inset-top));
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    background: transparent;
}

.view.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 1;
}

.header {
    background: transparent;
    padding: 1rem;
    padding-bottom: 0.5rem;
    text-align: left;
}

.header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #1a1a2e 0%, #5856D6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.scroll-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: calc(6rem + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
}

/* Stat Cards (Bento Grid) */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.stat-card {
    border-radius: 22px;
    padding: 18px 16px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -24px;
    right: -24px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    pointer-events: none;
}

.stat-card.yukiko {
    background: linear-gradient(135deg, #FF2D55 0%, #ff6e88 100%);
}

.stat-card.takuya {
    background: linear-gradient(135deg, #5856D6 0%, #7b79e8 100%);
}

.stat-card-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.82);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
}

.stat-card-value {
    font-size: 2.4rem;
    font-weight: 800;
    color: white;
    line-height: 1;
    letter-spacing: -2px;
}

.stat-card-unit {
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.72);
    margin-top: 6px;
    font-weight: 500;
}

/* Cards with Glassmorphism */
.card {
    background: var(--card-background);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--card-border);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 1.2rem;
    box-shadow: var(--shadow-soft);
}

.card h2 {
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--secondary-text);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* Tab Bar - Floating Style */
.tab-bar {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 30px;
    box-shadow: 0 10px 40px rgba(88, 86, 214, 0.18);
    display: flex;
    justify-content: space-around;
    padding: 10px;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.tab-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #C7C7CC;
    font-size: 0.7rem;
    width: 100%;
    padding: 5px 0;
    transition: all 0.3s ease;
    position: relative;
    border-radius: 18px;
}

.tab-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 18px;
    background: transparent;
    transition: background 0.25s ease;
}

.tab-item.active::before {
    background: rgba(88, 86, 214, 0.1);
}

.tab-item i {
    font-size: 1.4rem;
    margin-bottom: 4px;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-item.active {
    color: var(--takuya-color);
}

.tab-item.active i {
    transform: scale(1.1) translateY(-2px);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.8rem;
    font-weight: 600;
    color: var(--secondary-text);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.form-control {
    width: 100%;
    padding: 16px;
    border: none;
    background: rgba(255, 255, 255, 0.65);
    border-radius: 16px;
    font-size: 1.1rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    transition: all 0.2s;
}

.form-control:focus {
    background: white;
    outline: none;
    box-shadow: 0 0 0 2px var(--takuya-color);
}

.segmented-control {
    display: flex;
    background: rgba(118, 118, 128, 0.12);
    border-radius: 12px;
    padding: 3px;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 10px;
    margin: 0;
    border-radius: 9px;
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    color: var(--text-color);
    text-transform: none;
    letter-spacing: normal;
    font-weight: 500;
    cursor: pointer;
}

.segmented-control input:checked+label {
    background: white;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
    font-weight: 600;
}

.submit-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #5856D6 0%, #007AFF 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 1.5rem;
    box-shadow: 0 8px 24px rgba(88, 86, 214, 0.35);
    transition: transform 0.1s, box-shadow 0.2s;
}

.submit-btn:active {
    transform: scale(0.98);
}

.submit-btn:hover {
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(88, 86, 214, 0.45);
}

/* Stepper */
.stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.65);
    border-radius: 16px;
    padding: 10px;
}

.stepper button {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: none;
    background: white;
    color: var(--takuya-color);
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s;
}

.stepper button:active {
    transform: scale(0.95);
}

.stepper input {
    width: 100px;
    text-align: center;
    border: none;
    font-size: 1.8rem;
    font-weight: 700;
    background: transparent;
    color: var(--text-color);
}

/* List Tabs */
.list-tabs {
    background: rgba(118, 118, 128, 0.12);
    border-radius: 12px;
    padding: 3px;
    margin-bottom: 1.2rem;
    display: flex;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 9px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
}

.tab-btn.active {
    background: white;
    color: black;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
    font-weight: 600;
}

/* Record Cards (list view) */
.record-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.record-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease;
}

.record-card:active {
    transform: scale(0.98);
}

.record-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.record-dot.done { background: #34C759; }
.record-dot.pending { background: #FF9F0A; }

.record-body {
    flex: 1;
    min-width: 0;
}

.record-date {
    font-size: 0.76rem;
    color: var(--secondary-text);
    margin-bottom: 2px;
    font-weight: 500;
}

.record-content {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.record-content.empty {
    color: var(--secondary-text);
    font-weight: 400;
    font-style: italic;
}

.record-points {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-color);
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.record-edit-btn {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    border: none;
    background: rgba(88, 86, 214, 0.08);
    color: var(--takuya-color);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.15s;
}

.record-edit-btn:active {
    background: rgba(88, 86, 214, 0.18);
}

/* Dashboard Period Selector */
.period-selector {
    background: rgba(118, 118, 128, 0.08);
    border-radius: 20px;
    padding: 4px;
    display: flex;
    justify-content: space-between;
}

.period-btn {
    flex: 1;
    padding: 8px 0;
    border-radius: 16px;
    border: none;
    background: transparent;
    color: var(--secondary-text);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.period-btn.active {
    background: white;
    color: var(--text-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: rgba(255, 255, 255, 0.92);
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #5856D6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-modal {
    float: right;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--secondary-text);
    line-height: 1;
    margin-top: -4px;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.modal-actions button {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

.btn-delete {
    background: #ffe5e5;
    color: #ff3b30;
}

.btn-save {
    background: linear-gradient(135deg, #5856D6 0%, #007AFF 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(88, 86, 214, 0.3);
}

/* トースト通知 */
.toast {
    position: fixed;
    top: max(1.2rem, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%) translateY(-150%);
    background: rgba(30, 30, 30, 0.92);
    color: white;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    backdrop-filter: blur(10px);
    max-width: 90%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success { background: rgba(48, 176, 99, 0.95); }
.toast.error   { background: rgba(255, 59, 48, 0.95); }

/* ローディング状態 */
.submit-btn:disabled,
.btn-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* DB接続インジケーター */
.db-indicator {
    position: fixed;
    bottom: 5px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.58rem;
    color: rgba(0, 0, 0, 0.22);
    z-index: 99;
    pointer-events: none;
    letter-spacing: 0.4px;
    font-weight: 500;
}

/* もっと見るボタン */
.load-more-btn {
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    background: rgba(88, 86, 214, 0.08);
    border: none;
    border-radius: 16px;
    color: var(--takuya-color);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.load-more-btn:active {
    background: rgba(88, 86, 214, 0.16);
}
