/*
    AniPhone Style System
    Design Goal: To create a highly realistic, layered, and deep iOS-style interface.
    The core visual language combines the glassmorphism effect with micro-interactions 
    to create a transparent, modern, and textured digital product experience.
*/

:root {
    --text-light: #fff;
    --text-dark: #000;
    --text-dark-secondary: rgba(0, 0, 0, 0.6);
    --text-dark-tertiary: rgba(0, 0, 0, 0.4);
    --glass-bg-light: rgba(255, 255, 255, 0.25);
    --glass-border-light: rgba(255, 255, 255, 0.35);
    --anim-spring: cubic-bezier(0.68, -0.55, 0.27, 1.55);
    --primary: #007aff;
    --red: #ff3b30;
    --green: #34c759;
    --white-bg: #fff;
    --worldbook-bg-grad: linear-gradient(160deg, #f0f0f0, #b0b0b0, #222);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* --- Global Interaction Reset (Tap Highlight & Selection) --- */
* {
    -webkit-tap-highlight-color: transparent !important;
    -ms-tap-highlight-color: transparent !important;
    outline: none !important;
    -webkit-focus-ring-color: transparent;
}
*::-moz-focus-inner {
    border: 0;
}
a, button, .app-icon, .dynamic-island, .card, .card-content, 
.worldbook-tab-btn, .worldbook-category-chip, .worldbook-add-btn, .worldbook-menu-btn, 
.worldbook-back-btn, .page-indicators .dot, .dock .app-icon {
    user-select: none;
    -webkit-user-select: none;
}

body {
    display: grid;
    place-items: center;
    height: 100vh;
    background: linear-gradient(160deg, #3a3a3a, #1a1a1a);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
}

.iphone-screen {
    width: 390px;
    height: 844px;
    background: linear-gradient(160deg, #f0f0f0, #b0b0b0, #222);
    border-radius: 40px;
    box-shadow: 0 0 0 10px #111, 0 10px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- Dynamic Island --- */
.dynamic-island {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 36px;
    background: #000;
    border-radius: 18px;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 12px;
    transition: all 0.5s var(--anim-spring);
}

.dynamic-island.expanded {
    width: 370px;
    height: 80px;
}

.dynamic-island .camera {
    width: 10px;
    height: 10px;
    background-color: #1c1c1e;
    border-radius: 50%;
}

.dynamic-island:active {
    opacity: 0.8;
    transition: opacity 0.1s ease;
}

.island-content { 
    display: flex; 
    align-items: center; 
    width: 100%; 
    padding: 0 20px;
    color: var(--text-light); 
    opacity: 0; 
    animation: fadeIn 0.3s 0.2s forwards; 
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Music State */
.music-content { justify-content: space-between; }
.music-content .album-art { width: 50px; height: 50px; background: #333; border-radius: 8px; display: grid; place-items: center; font-size: 24px; }
.music-content .song-info { flex-grow: 1; margin: 0 15px; }
.music-content .song-title { font-weight: 600; }
.music-content .artist-name { font-size: 14px; opacity: 0.7; }
.music-content .playback-controls { display: flex; align-items: center; gap: 15px; font-size: 16px; }
.music-content .play { font-size: 20px; }

/* Call State */
.call-content { justify-content: space-between; }
.call-content .caller-info .caller-name { font-weight: 600; }
.call-content .caller-info .call-duration { color: #4CD964; }
.call-content .call-actions .end-call { width: 44px; height: 44px; background: #ff3b30; border-radius: 50%; display: grid; place-items: center; font-size: 20px; transform: rotate(135deg); }

/* Notification State */
.notification-content { gap: 15px; }
.notification-content .app-logo { font-size: 36px; }
.notification-content .notification-text { font-weight: 600; }

/* Widgets State */
.widgets-content { justify-content: space-around; }
.widgets-content .widget-control { padding: 8px 15px; background: rgba(255, 255, 255, 0.2); border-radius: 20px; cursor: pointer; transition: background 0.2s; }
.widgets-content .widget-control:hover { background: rgba(255, 255, 255, 0.3); }


/* --- Main Content --- */
#app-home { display: flex; flex-direction: column; flex-grow: 1; background: none; }
.main-content-home { flex-grow: 1; overflow: hidden; }
.pages-container {
    display: flex;
    height: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Firefox */
}
.pages-container::-webkit-scrollbar { display: none; /* Safari & Chrome */ }

.page {
    flex: 0 0 100%;
    scroll-snap-align: start;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.top-area .time {
    font-size: 95px;
    font-weight: 600;
    color: var(--text-dark);
    text-align: center;
    margin-top: 140px; /* Further moved down as per new spec */
}

/* Page 1 Layout */
.page-1-widgets { display: flex; gap: 20px; margin-top: 100px; /* Further moved down as per V2 spec */ }
.page-1-widgets > div { width: 50%; }

.memo-widget {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 15px;
    height: 150px;
    color: var(--text-dark);
}
.memo-widget h4 { font-weight: 600; margin-bottom: 8px; }
.memo-widget ul { list-style: none; color: var(--text-dark-secondary); font-size: 14px; }

.right-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Page 2 Layout (Visually Optimized) */
.page-2-layout { display: flex; flex-direction: column; gap: 20px; flex-grow: 1; margin-top: 160px; /* Further moved down as per V2 spec */ align-items: center; /* Center content horizontally */ }
.top-section, .bottom-section { display: flex; gap: 15px; width: 100%; justify-content: space-between; }
.large-image-placeholder {
    width: calc(65px * 2 + 15px);
    height: calc(65px * 2 + 15px);
    flex-shrink: 0;
    border-radius: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.large-image-placeholder::before {
    content: "🏞️";
    font-size: 64px;
    opacity: 0.9;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.large-image-placeholder::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.2), transparent 70%);
    pointer-events: none;
}
.app-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

.anniversary-card {
    width: calc(65px * 2 + 15px);
    height: calc(65px * 2 + 15px); /* Match height of app grid */
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #000;
}

.anniversary-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
}

.anniversary-days {
    font-size: 36px;
    font-weight: 700;
    color: #333;
}

/* --- App Icons --- */
.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.app-icon:hover { transform: translateY(-3px); }

.app-icon span {
    width: 65px;
    height: 65px;
    background: var(--glass-bg-light);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 25px;
    display: grid;
    place-items: center;
    font-size: 32px;
    border: 1px solid var(--glass-border-light);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}
.app-icon label {
    color: var(--text-dark);
    font-weight: 500;
    font-size: 13px;
}

.app-icon:active span {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.4); /* Brighter for feedback */
    transition: transform 0.1s ease, background-color 0.1s ease;
}

/* --- Dock --- */
.dock {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 90px;
    background: rgba(180, 180, 180, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 45px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 20px;
    flex-shrink: 0;
}
.dock .app-icon span {
    width: 52px;
    height: 52px;
    border-radius: 18px;
}
.dock .app-icon label {
    display: none; /* Hide labels in dock */
}

/* --- Page Indicators --- */
.page-indicators {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px; /* above dock */
}
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    transition: background 0.3s;
}
.dot.active {
    background: rgba(0, 0, 0, 0.7);
}

/* --- App Container --- */
.app-container {
    display: none;
    flex-direction: column;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-grad); /* Consistent background */
}

.app-container.active {
    display: flex;
}

/* --- Worldbook App Specific Styles --- */
#app-worldbook {
    background: var(--worldbook-bg-grad);
    color: var(--text-dark);
}

.worldbook-dynamic-island-placeholder { height: 60px; width: 100%; flex-shrink: 0; }
.worldbook-top-bar {
    padding: 0 10px; /* Adjust padding */
    flex-shrink: 0;
    display: flex;
    align-items: center;
    height: 44px; /* More standard height */
}

.worldbook-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--primary); /* iOS blue for interactive elements */
    font-size: 32px;       /* Larger arrow */
    font-weight: 300;      /* Thinner arrow */
    cursor: pointer;
    width: 44px;           /* Ensure large tap area */
    height: 44px;          /* Ensure large tap area */
    padding: 0;
    margin-left: -8px;     /* Visually align to the edge */
    transition: opacity 0.15s ease;
}

.worldbook-back-btn:active {
    opacity: 0.4; /* Stronger feedback on tap */
}
.worldbook-main-content { flex-grow: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }

.worldbook-page { display: none; flex-direction: column; height: 100%; padding: 0 16px; }
.worldbook-page.active { display: flex; }

.worldbook-page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.worldbook-page-title { margin: 0; font-size: 24px; font-weight: 700; color: var(--text-dark); }
.worldbook-add-btn, .worldbook-menu-btn { font-size: 28px; background: none; border: none; color: var(--primary); cursor: pointer; padding: 4px; }
.worldbook-item-list { flex-grow: 1; overflow-y: auto; padding: 4px 4px 20px 4px; margin: 0 -4px; list-style: none; }
.worldbook-item-list::-webkit-scrollbar { display: none; }

#app-worldbook .card {
  background: var(--glass-bg-light);
  backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
  border: 1px solid var(--glass-border-light);
  border-radius: 16px; padding: 12px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
#app-worldbook .card.enabled-jailbreak,
#app-worldbook .card.enabled {
  background: rgba(0, 122, 255, 0.15);
  border-color: rgba(0, 122, 255, 0.5);
}
#app-worldbook .card-content { flex-grow: 1; cursor: pointer; overflow: hidden; }
#app-worldbook .card-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--text-dark); }
#app-worldbook .card-summary { margin: 4px 0 0; font-size: 13px; color: var(--text-dark-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#app-worldbook .card-meta { font-size: 12px; color: var(--text-dark-tertiary); margin-top: 8px; }

#app-worldbook .card:active {
    background: rgba(255, 255, 255, 0.5); /* Increase opacity for feedback */
    transform: scale(0.98);
    transition: transform 0.1s ease, background-color 0.1s ease;
}

#app-worldbook .ios-switch { position: relative; width: 51px; height: 31px; flex-shrink: 0; cursor: pointer; }
#app-worldbook .ios-switch input { opacity: 0; width: 0; height: 0; }
#app-worldbook .slider { position: absolute; inset: 0; background-color: #e9e9eb; border-radius: 34px; transition: .4s; }
#app-worldbook .slider:before { position: absolute; content: ""; height: 27px; width: 27px; left: 2px; bottom: 2px; background-color: var(--white-bg); border-radius: 50%; transition: .4s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
#app-worldbook input:checked + .slider { background-color: var(--green); }
#app-worldbook input:checked + .slider:before { transform: translateX(20px); }

.worldbook-bottom-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); padding: 7px 16px 11px;
  background: rgba(240, 240, 240, 0.5);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.1); gap: 8px;
}
.worldbook-tab-btn { border: none; background: none; color: var(--text-dark-secondary); font-size: 16px; font-weight: 500; cursor: pointer; padding: 7px 0 11px; position: relative; transition: color 0.2s; }
.worldbook-tab-btn.active { color: var(--primary); font-weight: 600; }
.worldbook-tab-btn.active::after { content: ''; position: absolute; bottom: 6px; left: 20%; right: 20%; height: 3px; background: var(--primary); border-radius: 2px; }

.worldbook-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.4); display: none; justify-content: center; align-items: flex-end; z-index: 300; }
.worldbook-modal-panel { width: 100%; background: #f7f7f7; border-radius: 20px 20px 0 0; padding: 16px; transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); display: flex; flex-direction: column; gap: 12px; max-height: 80vh; color: var(--text-dark); }
.worldbook-modal-overlay.active { display: flex; }
.worldbook-modal-overlay.active .worldbook-modal-panel { transform: translateY(0); }
.worldbook-form-group { display: flex; flex-direction: column; gap: 6px; }
.worldbook-form-group label { font-size: 14px; font-weight: 500; color: var(--text-dark-secondary); }
.worldbook-form-input, .worldbook-form-textarea, .worldbook-form-select { width: 100%; border: 1px solid #ddd; padding: 10px; border-radius: 8px; font-size: 16px; background: var(--white-bg); }
.worldbook-form-textarea { min-height: 120px; resize: vertical; }
.worldbook-form-actions { display: flex; gap: 10px; margin-top: 8px; }
.worldbook-form-btn { flex-grow: 1; padding: 12px; font-size: 16px; border-radius: 10px; border: none; cursor: pointer; }
.worldbook-btn-save { background: var(--primary); color: white; }
.worldbook-btn-delete { background: var(--red); color: white; }
.worldbook-btn-cancel { background: #e5e5ea; color: var(--text-dark); }

#worldbook-local-categories-container { display: flex; overflow-x: auto; padding-bottom: 12px; gap: 8px; margin: 0 -16px; padding: 0 16px; }
#worldbook-local-categories-container::-webkit-scrollbar { display: none; }
.worldbook-category-chip { padding: 8px 14px; border-radius: 20px; background: var(--glass-bg-light); border: 1px solid var(--glass-border-light); backdrop-filter: blur(10px); font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.worldbook-category-chip.active { background: var(--primary); color: var(--white-bg); border-color: transparent; font-weight: 600; }
#worldbook-category-management-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid #eee; }
#worldbook-category-management-list li.is-default { color: #999; }
#worldbook-category-management-list button { background: none; border: none; cursor: pointer; font-size: 18px; }

/* --- Settings App Styles --- */
#app-settings {
    --bg-main: #FFFFFF;
    --bg-secondary: #FAFAFA;
    --bg-btn: #F2F2F7;
    --text-main: #262626;
    --text-btn: #262626;
    --text-secondary: #8e8e8e;
    --primary-color: #007AFF;
    --selected-bg: #E5F1FF;
    --border-color: #dbdbdb;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    font-family: var(--font-family);
    background: var(--bg-secondary);
}

#app-settings .page {
    display: none;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-secondary);
    padding: 0; /* Override main page padding */
}

#app-settings .page.active {
    display: flex;
}

#app-settings .page-header {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 54px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    margin-top: 60px; /* Added for Dynamic Island space */
    border: none !important;
    box-shadow: none !important;
    flex-shrink: 0;
}

#app-settings .page-header .back-btn {
    font-size: 22px;
    color: var(--primary-color);
    background: none;
    border: none;
    cursor: pointer;
    padding-right: 16px;
    margin-left: -8px;
}

#app-settings .page-header .title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-main);
}

#app-settings .page-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 17px 13px;
}

#app-settings .card {
    background-color: var(--bg-main);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    cursor: pointer;
}

#app-settings .btn {
    width: 100%;
    min-height: 37px;
    padding: 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    background-color: var(--bg-btn);
    color: var(--text-btn);
    transition: opacity 0.1s ease;
}

#app-settings .btn:active { opacity: 0.7; }
#app-settings .btn:disabled { opacity: 0.5; cursor: not-allowed; }

#app-settings .form-group { margin-bottom: 17px; }

#app-settings .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 7px;
}

#app-settings .form-input,
#app-settings .form-select {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: 7px;
    background-color: var(--bg-main);
}

#app-settings .d-flex { display: flex; }
#app-settings .align-center { align-items: center; }
#app-settings .gap-13 { gap: 13px; }

#app-settings .profile-card-large {
    padding: 17px 13px;
    display: flex;
    align-items: center;
    gap: 13px;
}

#app-settings .profile-card-large .profile-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #efefef;
    display: grid;
    place-items: center;
    font-size: 25px;
    overflow: hidden;
    flex-shrink: 0;
}

#app-settings .profile-card-large .profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
#app-settings .profile-card-large .profile-info { display: flex; flex-direction: column; gap: 3px; }
#app-settings .profile-card-large .profile-info .name { font-size: 18px; font-weight: 600; color: var(--text-main); }
#app-settings .profile-card-large .profile-info .birthday { font-size: 12px; font-weight: 600; color: var(--text-main); }

#app-settings .menu-item {
    padding: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#app-settings .menu-item .title { font-size: 14px; font-weight: 600; color: var(--text-main); }
#app-settings .menu-item .value { font-size: 14px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 7px; }
#app-settings .menu-item .value .arrow { font-size: 17px; color: #c7c7cc; }

#app-settings #page-edit-profile .avatar-editor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 17px;
    cursor: pointer;
}

#app-settings #page-edit-profile .avatar-preview {
    width: 69px;
    height: 69px;
    border-radius: 50%;
    background-color: #efefef;
    display: grid;
    place-items: center;
    font-size: 34px;
    overflow: hidden;
}

#app-settings #page-edit-profile .avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
#app-settings #page-edit-profile .avatar-editor span { font-size: 12px; color: var(--primary-color); font-weight: 500; }
#app-settings #avatar-file-input { display: none; }

#app-settings #api-test-result {
    font-size: 12px;
    margin-top: 8px;
    padding: 7px;
    border-radius: 7px;
}

#app-settings #api-test-result.success { background-color: #e6f9ee; color: #00b050; }
#app-settings #api-test-result.error { background-color: #fde8e8; color: var(--text-main); }

#app-settings #page-wallet .balance-display { text-align: center; margin-bottom: 17px; }
#app-settings #page-wallet .balance-display .amount { font-size: 29px; font-weight: 700; }
#app-settings #page-wallet .balance-display .label { font-size: 12px; color: var(--text-secondary); }
#app-settings #page-wallet .transaction-history .title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
#app-settings #page-wallet .transaction-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #efefef; font-size: 12px; }

#app-settings #page-display .setting-group { margin-bottom: 17px; }
#app-settings #page-display .setting-group .title { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 8px; }
#app-settings #page-display .mode-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
#app-settings #page-display .mode-btn { padding: 8px; border-radius: 7px; border: none; font-weight: 500; background-color: var(--bg-btn); color: var(--text-btn); }
#app-settings #page-display .mode-btn.active { background-color: var(--selected-bg); color: var(--primary-color); }

#app-settings #page-display .brightness-control { display: flex; align-items: center; gap: 13px; }
#app-settings #page-display .brightness-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; background: #efefef; border-radius: 2px; outline: none; }
#app-settings #page-display .brightness-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--bg-main);
    cursor: pointer;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* --- Contacts App Styles --- */
#app-contacts {
    --primary-color: #007AFF;
    --destructive-color: #FF3B30;
    --bg-color: #f5f5f7;
    --text-color: #000000;
    --text-color-secondary: rgba(60, 60, 67, 0.6);
    --card-bg: rgba(255, 255, 255, 0.7);
    --glass-bg: rgba(245, 245, 247, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --input-bg: #ffffff;
    --btn-bg: #e5e5ea;
    --anim-fast: 0.2s ease;
    --anim-spring: cubic-bezier(0.68, -0.55, 0.27, 1.55);
    background: var(--bg-color) !important;
}

#app-contacts .app-page { display: none; flex-direction: column; width: 100%; height: 100%; position: absolute; top: 0; left: 0; background-color: var(--bg-color); }
#app-contacts .app-page.active { display: flex; animation: contacts-fadeIn 0.3s ease-in-out; }

@keyframes contacts-fadeIn { from { opacity: 0; } to { opacity: 1; } }

#app-contacts .dynamic-island-placeholder { height: 60px; flex-shrink: 0; }
#app-contacts .top-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; height: 44px; background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); z-index: 10; border-bottom: 1px solid var(--glass-border); }
#app-contacts .top-bar .title { font-size: 17px; font-weight: 600; text-align: center; flex-grow: 1; color: var(--text-color); }
#app-contacts .back-btn, #app-contacts .top-bar-placeholder { background: none; border: none; color: var(--primary-color); font-size: 17px; cursor: pointer; padding: 0 8px; min-width: 60px; text-align: left;}
#app-contacts .top-bar-placeholder { visibility: hidden; }
#app-contacts .content-area { flex-grow: 1; overflow-y: auto; }
#app-contacts .category-bar { display: flex; overflow-x: auto; gap: 8px; padding: 8px 16px; scrollbar-width: none; border-bottom: 1px solid var(--glass-border); }
#app-contacts .category-bar::-webkit-scrollbar { display: none; }
#app-contacts .category-tab { padding: 7px 14px; border-radius: 20px; background-color: var(--btn-bg); color: var(--text-color); font-size: 14px; white-space: nowrap; cursor: pointer; transition: all var(--anim-fast); border: none; }
#app-contacts .category-tab.active { background-color: var(--primary-color); color: white; font-weight: 600; }
#app-contacts .character-list { display: flex; flex-direction: column; }
#app-contacts .character-list-item { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--glass-border); cursor: pointer; }
#app-contacts .character-list-item:active { background-color: #e5e5ea; }
#app-contacts .character-list-item .avatar { width: 50px; height: 50px; border-radius: 50%; background-color: #ccc; border: 1px solid rgba(0,0,0,0.05); object-fit: cover; }
#app-contacts .character-list-item .name { font-size: 17px; font-weight: 500; color: var(--text-color); }
#app-contacts .empty-list-placeholder { text-align: center; color: var(--text-color-secondary); padding-top: 50px; }
#app-contacts .fab { position: absolute; bottom: 30px; right: 30px; width: 56px; height: 56px; border-radius: 28px; background-color: var(--primary-color); color: white; font-size: 36px; line-height: 56px; text-align: center; border: none; cursor: pointer; box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4); transition: transform 0.2s ease; user-select: none; }
#app-contacts .fab:active { transform: scale(0.95); }
#app-contacts .page-content { flex-grow: 1; overflow-y: auto; padding: 12px; }
#app-contacts .form-container, #app-contacts .detail-container { display: flex; flex-direction: column; gap: 16px; }
#app-contacts .detail-avatar-container, #app-contacts .edit-avatar-container { text-align: center; color: var(--text-color); }
#app-contacts .detail-avatar-container .avatar, #app-contacts .edit-avatar-container .avatar { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; margin: 0 auto 8px; background-color: #ccc; border: 2px solid white; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
#app-contacts .edit-avatar-container .avatar { cursor: pointer; }
#app-contacts .detail-avatar-container .name { font-size: 28px; font-weight: 700; }
#app-contacts .form-group { display: flex; flex-direction: column; gap: 8px; }
#app-contacts .form-group label { color: var(--text-color-secondary); font-weight: 500; padding-left: 4px; }
#app-contacts .form-group input, #app-contacts .form-group select, #app-contacts .form-group textarea { background-color: var(--input-bg); border: 1px solid #c8c8cd; border-radius: 8px; padding: 12px; color: var(--text-color); font-size: 16px; -webkit-appearance: none; appearance: none; }
#app-contacts .form-group textarea { min-height: 100px; resize: vertical; }
#app-contacts .btn-group { display: flex; gap: 12px; margin-top: 8px; }
#app-contacts .btn { flex-grow: 1; padding: 14px; border-radius: 10px; border: none; font-size: 17px; font-weight: 600; cursor: pointer; }
#app-contacts .btn-primary { background-color: var(--primary-color); color: white; }
#app-contacts .btn-secondary { background-color: var(--btn-bg); color: var(--text-color); }
#app-contacts .btn-destructive { background-color: var(--destructive-color); color: white; }
#app-contacts .modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.4); display: none; justify-content: center; align-items: flex-end; z-index: 100; }
#app-contacts .modal-overlay.active { display: flex; }
#app-contacts .modal-panel { width: 100%; background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 20px 20px 0 0; padding: 16px; transform: translateY(100%); animation: contacts-slideIn 0.4s var(--anim-spring) forwards; display: flex; flex-direction: column; gap: 16px; max-height: 80vh; }

@keyframes contacts-slideIn { to { transform: translateY(0); } }

#app-contacts .modal-header { font-size: 18px; font-weight: 600; text-align: center; color: var(--text-color); }
#app-contacts .modal-content { overflow-y: auto; }
#app-contacts #contacts-category-management-list li, #app-contacts .worldbook-import-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 8px; border-bottom: 1px solid var(--glass-border); }
#app-contacts #contacts-category-management-list input { flex-grow: 1; margin-right: 12px; background: white; border: 1px solid #ddd; border-radius: 8px; padding: 8px; }
#app-contacts .delete-category-btn { background: none; border: none; color: var(--destructive-color); font-size: 20px; cursor: pointer; }
#app-contacts .worldbook-import-group h3 { font-size: 16px; font-weight: 600; padding: 12px 8px; color: var(--text-color-secondary); }
#app-contacts .worldbook-import-item label { display: flex; align-items: center; gap: 12px; flex-grow: 1; cursor: pointer; }
#app-contacts .worldbook-import-item input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary-color); }
#app-contacts .worldbook-import-item .item-text { display: flex; flex-direction: column; }
#app-contacts .worldbook-import-item .item-title { font-weight: 500; color: var(--text-color); }
#app-contacts .worldbook-import-item .item-preview { font-size: 14px; color: var(--text-color-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
