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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #fafafa;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Login */
.login-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    text-align: center;
    padding: 3rem 2rem;
}

.login-box h1 {
    font-size: 1.6rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #555;
}

.login-box .subtitle {
    font-size: 0.85rem;
    color: #999;
    margin: 0.3rem 0 2rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 280px;
    margin: 0 auto;
}

.login-form input {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
    text-align: center;
}

.login-form input:focus {
    border-color: #aaa;
}

.login-form button {
    padding: 0.75rem;
    font-size: 0.95rem;
    border: none;
    border-radius: 8px;
    background: #555;
    color: #fff;
    cursor: pointer;
}

.login-form button:hover {
    background: #333;
}

.login-error {
    color: #c0392b;
    font-size: 0.85rem;
}

/* Header */
header {
    text-align: center;
    padding: 2rem 1rem 1rem;
    position: relative;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #555;
}

header .subtitle {
    font-size: 0.85rem;
    color: #999;
    margin-top: 0.3rem;
}

.logout-link {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.75rem;
    color: #bbb;
    text-decoration: none;
}

.logout-link:hover {
    color: #888;
}

/* Main */
main {
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}

.search-container {
    position: sticky;
    top: 0;
    background: #fafafa;
    padding: 1rem 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    overflow: hidden;
}

#search {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

#search:focus {
    border-color: #aaa;
}

.search-count {
    font-size: 0.8rem;
    color: #999;
    white-space: nowrap;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    transition: background 0.2s;
}

.btn-add {
    background: #555;
    color: #fff;
    font-size: 1.3rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-add:hover {
    background: #333;
}

.btn-save {
    background: #27ae60;
    color: #fff;
}

.btn-save:hover {
    background: #219a52;
}

.btn-danger {
    background: transparent;
    color: #c0392b;
    border: 1px solid #c0392b;
}

.btn-danger:hover {
    background: #c0392b;
    color: #fff;
}

/* Stone grid */
.stones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.stone-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 1.25rem;
    transition: box-shadow 0.2s;
    position: relative;
}

.stone-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.stone-card .stone-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.stone-card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.stone-card .description {
    font-size: 0.88rem;
    line-height: 1.5;
    color: #555;
}

.stone-card .keywords {
    margin-top: 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.stone-card .keyword {
    font-size: 0.7rem;
    background: #f0f0f0;
    color: #777;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}

.stone-card .card-actions {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.6rem;
    justify-content: flex-end;
}

.card-actions button {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.card-actions button:hover {
    border-color: #999;
    color: #555;
    background: #f5f5f5;
}

/* No results */
.no-results {
    text-align: center;
    color: #999;
    padding: 3rem 0;
    font-size: 0.95rem;
}

mark {
    background: #fff3cd;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    align-items: center;
    justify-content: center;
    z-index: 100;
    display: none;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal label {
    display: block;
    font-size: 0.8rem;
    color: #777;
    margin-bottom: 0.3rem;
    margin-top: 1rem;
}

.modal label:first-of-type {
    margin-top: 0;
}

.modal input[type="text"],
.modal textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    resize: vertical;
}

.modal input:focus,
.modal textarea:focus {
    border-color: #aaa;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    gap: 0.75rem;
}

.modal-actions .btn-save {
    flex: 1;
}

/* Confirm delete dialog */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.confirm-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.confirm-dialog {
    background: #fff;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.confirm-dialog p {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}
.confirm-dialog .confirm-sub {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}
.confirm-actions {
    display: flex;
    gap: 0.75rem;
}
.confirm-actions .btn {
    flex: 1;
    padding: 0.65rem 1rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 600;
}
.btn-cancel {
    background: #f0f0f0;
    color: #333;
}
.btn-cancel:hover {
    background: #e0e0e0;
}

.field-locked {
    background: #f5f5f5 !important;
    color: #888 !important;
    cursor: not-allowed;
}

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.75rem;
    color: #bbb;
    border-top: 1px solid #eee;
}

@media (max-width: 600px) {
    .stones-grid {
        grid-template-columns: 1fr;
    }
    header {
        padding: 1.5rem 1rem 0.5rem;
    }
    .modal {
        width: 95%;
        padding: 1.5rem;
    }
}

/* Photo upload zone (modal) */
.photo-upload-zone {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-upload-zone:hover {
    border-color: #aaa;
    background: #fafafa;
}

.photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: #999;
}

.photo-placeholder svg {
    opacity: 0.5;
}

.photo-placeholder span {
    font-size: 0.8rem;
}

.photo-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: 6px;
    object-fit: contain;
}

/* Add photo button on cards */
.btn-add-photo {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border: 2px dashed #ddd;
    border-radius: 6px;
    background: none;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    transition: border-color 0.2s, color 0.2s;
}

.btn-add-photo:hover {
    border-color: #999;
    color: #555;
}
