@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Serif+JP:wght@700&family=Roboto+Mono&display=swap');

:root {
    --bg-color: #f7f7f5;
    --card-bg: #ffffff;
    --text-primary: #37352f;
    --text-secondary: #787774;
    --accent-color: #2383e2;
    --accent-light: rgba(35, 131, 226, 0.1);
    --border-color: rgba(55, 53, 47, 0.09);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
    --serif-font: 'Noto Serif JP', serif;
    --sans-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif;
    --mono-font: 'Roboto Mono', monospace;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: var(--sans-font);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
}

h1, h2, h3 {
    margin: 0;
}

/* Layout */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.view {
    display: none;
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}

.view.active {
    display: block;
}

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

/* Header */
header {
    padding: 24px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: rgba(247, 247, 245, 0.8);
    backdrop-filter: blur(10px);
    z-index: 100;
}

header h1 {
    font-size: 28px;
    font-weight: 700;
}

.add-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent-light);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: transform 0.2s;
}

.add-btn:active {
    transform: scale(0.9);
}

/* Search Bar */
.search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper i {
    position: absolute;
    left: 12px;
    color: var(--text-secondary);
}

input[type="text"] {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: #fff;
    font-size: 16px;
    outline: none;
}

.scan-btn {
    padding: 10px;
    border-radius: 8px;
    background-color: var(--accent-light);
    color: var(--accent-color);
    border: none;
    cursor: pointer;
}

/* Book List */
.book-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.book-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.1s;
}

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

.book-cover {
    width: 60px;
    height: 88px;
    border-radius: 6px;
    object-fit: cover;
    background-color: #eee;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.book-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-family: var(--serif-font);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.progress-container {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
}

.progress-percent {
    font-family: var(--mono-font);
    font-size: 11px;
    color: var(--text-secondary);
    width: 35px;
    text-align: right;
}

/* Detail View */
.detail-header {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.detail-cover {
    width: 120px;
    height: 180px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.detail-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.detail-title {
    font-family: var(--serif-font);
    font-size: 22px;
    margin-bottom: 8px;
}

.detail-author {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: auto;
}

.action-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

/* Property List */
.property-list {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
}

.property-row {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

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

.prop-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    width: 120px;
}

.prop-value {
    flex: 1;
    text-align: right;
    font-weight: 600;
}

/* Logs */
.logs-section {
    margin-top: 24px;
}

.log-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.log-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.log-pages {
    padding: 4px 8px;
    background: var(--accent-light);
    color: var(--accent-color);
    font-family: var(--mono-font);
    font-size: 11px;
    border-radius: 4px;
    font-weight: 700;
}

.log-date {
    font-size: 11px;
    color: var(--text-secondary);
}

.log-memo {
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    align-items: flex-end;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-color);
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 24px 20px 40px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-title {
    font-weight: 700;
}

.close-modal {
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

/* Scanner */
#video-container {
    width: 100%;
    height: 250px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    margin-bottom: 20px;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 0 100vmax rgba(0,0,0,0.4);
    pointer-events: none;
    margin: 50px;
}

/* Utils */
.sr-only { display: none; }
.spinner {
    border: 2px solid rgba(0,0,0,0.1);
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
