:root {
    --ink: #211c16;
    --muted: #706c67;
    --accent: #f1b200;
    --accent-soft: #fff2c5;
    --paper: #ffffff;
    --line: #e9e5dd;
    --page: #f7f6f2;
    --shadow: 0 12px 34px rgba(44, 35, 18, .06);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { min-height: 100vh; height: auto; background: var(--page); color: var(--ink); line-height: 1.5; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid #d69a00; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

/* En-tête et navigation */
.header { position: sticky; top: 0; z-index: 50; width: 100%; box-shadow: 0 6px 22px rgba(33, 28, 22, .07); }
.top-topbar { justify-content: center; min-height: 28px; padding: 5px 20px; background: linear-gradient(90deg, #ffd455, #f1b200); color: #4c3700; text-align: center; font-size: 11px; letter-spacing: .015em; }
.top-topbar div { margin: 0; }
.topbar { min-height: 70px; gap: 24px; padding: 10px max(24px, calc((100vw - 1160px)/2)); background: rgba(255, 255, 255, .97); box-shadow: none; }
.topbar .logolink { flex: none; display: inline-flex; align-items: center; }
.topbar .logolink img { display: block; width: 145px; height: auto; max-height: 42px; margin: 0; object-fit: contain; }
.menu { display: flex; align-items: center; gap: 6px; margin: 0 auto; white-space: nowrap; }
.menu div, .menu div:hover { display: inline-flex; align-items: center; margin: 0; border: 0; }
.menu a { display: inline-flex; align-items: center; min-height: 42px; padding: 7px 13px; border-radius: 11px; font-weight: 700; font-size: 14px; }
.menu .menuSelected { border: 0 !important; border-radius: 11px; background: var(--accent-soft); }
.menu .menuSelected a { color: #6a4e00; }
.menu .menu-profile { display: none; }
.logbutton { flex: none; margin: 0; padding: 0; }
.logbutton_span { display: flex; align-items: center; gap: 8px; }
.logbutton_span div { display: inline-flex; flex-shrink: 0; float: none; width: auto !important; margin: 0; padding: 0; border: 0; border-radius: 11px; transform: none !important; }
.logbutton_span a { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: 8px 14px; font-size: 13px; font-weight: 800; text-align: center; white-space: nowrap; border-radius: 11px; }
.logbutton_span .login_button, .logbutton_span .logout_button { background: var(--accent); }
.logbutton_span .profile_button { border: 1px solid var(--line); background: #fff; }
.logbutton_span .login_button:hover, .logbutton_span .logout_button:hover { background: #ffd047; }

/* Cadre commun */
#userspage, #userspage_black { width: min(100%, 820px); margin: 0 auto; padding: 38px 20px 80px; font-size: 16px; }
.feed-intro { position: relative; margin: 0 0 28px; padding: 28px 32px; border-radius: 20px; background: linear-gradient(120deg, #fff6d8 0%, #fffaf0 70%, #ffffff 100%); border: 1px solid #f6e7b2; text-align: left; overflow: hidden; }
.feed-intro::after { content: ''; position: absolute; right: -45px; top: -66px; width: 205px; height: 205px; border: 28px solid rgba(241, 178, 0, .11); border-radius: 50%; pointer-events: none; }
.feed-intro > * { position: relative; z-index: 1; }
.eyebrow { display: block; margin-bottom: 5px; color: #956b00; font-size: 11px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.feed-intro h1, .feed-intro h2 { max-width: 590px; margin: 0 0 8px; font-size: clamp(28px, 4vw, 36px) !important; font-weight: 850; line-height: 1.2; letter-spacing: -.03em; }
.feed-intro p { max-width: 620px; margin: 0; color: #5d554a; font-size: 15px; }
.intro-action { display: inline-flex; align-items: center; gap: 12px; min-height: 43px; margin-top: 20px; padding: 10px 16px; border-radius: 11px; background: var(--ink); color: #fff; text-decoration: none; font-size: 14px; font-weight: 800; }
.intro-action:hover { background: #514018; }
.feed-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 28px 0 18px; }
.feed-heading h2 { margin: 0; font-size: 22px !important; letter-spacing: -.02em; }
.feed-heading span { color: var(--muted); font-size: 13px; }
.back-link { display: inline-flex; align-items: center; gap: 9px; margin-bottom: 22px; color: #5b4b21; text-decoration: none; font-size: 14px; font-weight: 800; }
.back-link:hover { text-decoration: underline; }
.empty-state { padding: 38px 24px; border: 1px dashed #d9d2c6; border-radius: 16px; background: #fff; color: var(--muted); text-align: center; }

/* Cartes de publication */
.img_display, .create_post, .settings-card { width: 100%; max-width: none; margin: 0 0 22px !important; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow); }
.img_display { overflow: hidden; }
.post-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 76px; padding: 13px 19px; }
.post-author { display: inline-flex; align-items: center; gap: 11px; min-width: 0; text-decoration: none; }
.post-avatar, .post-avatar img { display: block; flex: none; width: 46px; height: 46px; border: 2px solid #fff; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px #eadfc6; }
.post-author-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.post-author-text .name { display: block; overflow: hidden; max-width: 100%; margin: 0; color: var(--ink); font-size: 14px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.post-author-text .login { display: block; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.post-author:hover .name { text-decoration: underline; }
.post-badge { flex: none; padding: 6px 10px; border-radius: 999px; background: var(--accent-soft); color: #775600; font-size: 11px; font-weight: 800; }
.post-follow { flex: none; }
.post-media { display: block; background: #f4f1e9; }
.post-media .image, .guest-post > a > .image { display: block; width: 100%; height: auto; max-height: 690px; object-fit: contain; background: #f4f1e9; }
.guest-post > a { display: block; }
.post-body { padding: 18px 20px 16px; }
.post-rating { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-bottom: 13px; }
.post-rating .score2, .post-rating .score_iframe { clear: none; float: none; width: auto; height: auto; margin: 0; font-size: 13px; }
.score2 strong { color: #9b7100; font-size: 16px; }
.score2 span { margin-left: 4px; color: var(--muted); }
.post-copy .titre { margin: 0; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.post-copy .titre a { margin-right: 4px; font-weight: 850; }
.post-copy .description { margin: 4px 0 0; color: #55504a; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.post-join { display: inline-block; margin-top: 14px; color: #846000; text-decoration: none; font-size: 13px; font-weight: 800; }
.post-join:hover { text-decoration: underline; }
.guest-post .post-copy { padding: 17px 20px 20px; }
.vote-remove, .text-button { padding: 0; border: 0; background: transparent; color: #846000; font-size: 13px; font-weight: 800; }
.vote-remove:hover, .text-button:hover { text-decoration: underline; }
.post-rating .stars { display: flex; flex-direction: row-reverse; gap: 2px; float: none; overflow: visible; width: auto; height: auto; margin: 0; }
.post-rating .stars input[type=radio] { position: absolute; display: block; width: 1px; height: 1px; opacity: 0; }
.post-rating .stars label { display: block; float: none; width: 27px; height: 31px; padding: 0; }
.post-rating .stars label::after { width: 27px; color: #b8b2a5; font-size: 26px; line-height: 1; }
.post-rating .stars input:focus-visible + label { outline: 2px solid #d69a00; outline-offset: 2px; border-radius: 4px; }
.post-comments { display: grid; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.post-comment { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; font-size: 13px; }
.post-comment p { margin: 0; overflow-wrap: anywhere; }
.post-comment a { margin-right: 4px; color: var(--ink); text-decoration: none; font-weight: 850; }
.post-comment a:hover { text-decoration: underline; }
.post-comment .delete_button { flex: none; color: #8f721f; }
.comment-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--line); }
.comment-form .write_comment { flex: 1 1 200px; width: auto; min-width: 0; min-height: 39px; margin: 0; padding: 7px 10px; border: 1px solid #e4dfd5; border-radius: 9px; background: #faf9f6; font-size: 14px; }
.comment-form .write_comment:focus { border-color: var(--accent); background: #fff; outline: none; }
.comment-form .publish_comment { flex: none; float: none; min-height: 39px; margin: 0; padding: 7px 13px; border-radius: 9px; background: var(--accent-soft); color: #735100; font-size: 13px; }
.comment-form .publish_comment:hover { background: #ffe18b; transform: none; }
.comment-form .error5 { flex-basis: 100%; color: #a3352a; font-size: 12px; }
.comment-form .error5:empty { display: none; }
.post-edit { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.post-edit summary { width: fit-content; color: #795a08; font-size: 13px; font-weight: 800; cursor: pointer; }
.post-edit form { margin-top: 13px; }
.post-edit label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 800; }
.edit-row { display: flex; align-items: center; gap: 8px; }
.edit-row input { flex: 1; min-width: 0; min-height: 39px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #faf9f6; }
.post-edit .delete_button { margin: 0; padding: 4px 0; color: #a44d3d; }

/* Appels à l'action et boutons */
.create_post { display: flex; align-items: center; gap: 13px; padding: 14px 18px; }
.create_post .post-avatar { width: 43px; height: 43px; }
.create_post .field_photo { position: static; display: flex; align-items: center; justify-content: space-between; flex: 1; min-width: 0; min-height: 43px; margin: 0; padding: 7px 9px 7px 16px; border: 1px solid #ece7dd; border-radius: 999px; background: #f7f6f2; color: #6b655d; text-align: left; font-size: 13px; }
.create_post .field_photo span { position: static; overflow: hidden; margin: 0; color: inherit; text-overflow: ellipsis; white-space: nowrap; font-size: inherit; }
.create_post .field_photo strong { flex: none; display: grid; place-items: center; width: 29px; height: 29px; margin-left: 10px; border-radius: 50%; background: var(--accent); color: var(--ink); font-size: 22px; line-height: 1; }
.showsub_button, .sub_profile_button, .unsubscribe_button, .roundedButton, .roundedButton_photo, .modify_description_submit { display: inline-flex; justify-content: center; align-items: center; min-height: 39px; padding: 8px 13px; border-radius: 9px; font-family: inherit; font-size: 13px; font-weight: 800; line-height: 1.2; text-decoration: none; }
.showsub_button, .sub_profile_button, .roundedButton, .roundedButton_photo, .modify_description_submit { border: 1px solid var(--accent); background: var(--accent); color: var(--ink); }
.showsub_button:hover, .sub_profile_button:hover, .roundedButton:hover, .roundedButton_photo:hover { background: #ffd455; }
.unsubscribe_button { border: 1px solid #ded8cb; background: #fff; color: var(--ink); }
.unsubscribe_button:hover { border-color: #a39882; }

/* Profil et formulaires */
.profile-page { width: min(100%, 860px) !important; }
.profile-hero { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; align-items: start; gap: 22px; width: 100%; margin: 0 0 24px !important; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.profile-hero-avatar { display: block; width: 112px; height: 112px; border-radius: 24px; object-fit: cover; background: #f1ebdc; }
.profile-hero h1 { margin: 0; font-size: clamp(22px, 4vw, 31px); line-height: 1.2; letter-spacing: -.025em; }
.profile-handle { margin-top: 3px; color: var(--muted); font-size: 14px; }
.profile-description { max-width: 480px; margin-top: 13px; color: #554e44; font-size: 14px; }
.profile-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 18px; }
.profile-stats span, .profile-stats button { display: inline-flex; align-items: baseline; gap: 5px; min-height: 28px; padding: 0; border: 0; background: transparent; color: #514a40; font-size: 12px; }
.profile-stats button:hover { text-decoration: underline; }
.profile-stats strong { color: var(--ink); font-size: 16px; }
.profile-hero-action { white-space: nowrap; }
.profile-edit-page { width: min(100%, 760px) !important; }
.settings-card { padding: 3px 25px; }
.settings-section { padding: 25px 0; border-bottom: 1px solid var(--line); }
.settings-section:last-child { border-bottom: 0; }
.settings-section h2 { margin: 0; font-size: 19px !important; line-height: 1.3; }
.settings-section p { margin: 5px 0 16px; color: var(--muted); font-size: 13px; }
.settings-section label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 800; }
.settings-section input:not([type=hidden]), .settings-section textarea { display: block; width: 100%; min-width: 0; min-height: 42px; padding: 10px 12px; border: 1px solid #dcd6c9; border-radius: 9px; background: #fff; color: var(--ink); font-size: 14px; resize: vertical; }
.settings-section input:focus, .settings-section textarea:focus { border-color: var(--accent); outline: none; }
.settings-section .roundedButton { width: auto; min-width: 130px; margin: 0; }
#modifpp { margin: 0; color: var(--ink); }
#modifpp:hover { transform: none; }
.settings-avatar { display: flex; align-items: center; gap: 20px; }
.settings-avatar-img { width: 82px; height: 82px; border-radius: 18px; object-fit: cover; }
.settings-avatar p { margin-bottom: 10px; }
.settings-actions, .settings-form-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.settings-form-row input { flex: 1 1 240px; }
.settings-section .error { display: block; margin-top: 6px; font-size: 12px; }
.settings-section .text-button { margin-top: 9px; }
.detail-page { width: min(100%, 860px) !important; }
.detail-page .post-media .image { max-height: 760px; }

/* Fenêtres de publication, de profil et d'abonnements */
.addphoto, .changepp, .showFollowers, .showFollowing { z-index: 100; padding: 16px; }
.hider { background: rgba(28, 23, 17, .66); backdrop-filter: blur(2px); }
.addphoto form, .changepp form, .showFollowers_block, .showFollowing_block { position: relative; z-index: 101; width: min(100%, 580px); max-height: min(90vh, 780px); overflow-y: auto; margin: 0; padding: 20px 24px 24px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 30px 90px rgba(19, 14, 7, .28); filter: none; }
.addphoto form > input[type=hidden], .changepp form > input[type=hidden] { display: none; }
.addphoto #cancel_addphoto, .changepp #cancel_addphoto, .showFollowers #cancel_addphoto, .showFollowing #cancel_addphoto { position: absolute; top: 13px; right: 13px; left: auto; float: none; display: grid; place-items: center; width: 36px; height: 36px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: #f1eee7; color: #443d33; font-size: 22px; line-height: 1; }
.title_addphoto { margin: 0 30px 17px 0; text-align: left; }
.title_addphoto h3 { margin: 0; font-size: 22px; font-weight: 850; }
.addphoto .profilepicture2, .addphoto .name2 { display: none; }
.addphoto .margin_addphoto { margin: 0; }
.addphoto .undereachother { margin-bottom: 12px; }
.addphoto #title, .addphoto #description { display: block; width: 100%; min-height: 44px; margin: 0; padding: 11px 13px; border: 1px solid #dcd6c9; border-radius: 9px; background: #fff; font-size: 14px; resize: vertical; }
.addphoto #description { min-height: 100px; }
.addphoto label.custom-file-upload, .changepp label.custom-file-upload { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 70px; padding: 14px 16px; border: 1px dashed #d9c995; border-radius: 10px; background: #fffaf0; font-size: 14px; }
.addphoto label.custom-file-upload:hover, .changepp label.custom-file-upload:hover { border-color: var(--accent); background: #fff4d4; }
.custom-file-upload .icon { position: static; width: 28px; height: 28px; }
.addphoto label.image-upload { position: relative; cursor: pointer; }
.addphoto .image-upload input[type=file] { position: absolute; display: block; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.addphoto .image-upload:focus-within { outline: 3px solid #d69a00; outline-offset: 3px; }
.addphoto label.image-upload.has-preview { display: block; min-height: 0; padding: 0; overflow: hidden; border-style: solid; background: #f4f1e9; }
.addphoto .image-upload.has-preview .upload-prompt, .addphoto .image-upload.has-preview .upload-icon { display: none; }
.addphoto .image-upload .image-preview { display: block; width: 100%; max-height: 320px; object-fit: contain; }
.addphoto .image-upload .preview-hint { position: absolute; right: 12px; bottom: 12px; padding: 7px 10px; border-radius: 8px; background: rgba(33, 28, 22, .88); color: #fff; font-size: 12px; font-weight: 800; }
.addphoto .image-upload .image-preview[hidden], .addphoto .image-upload .preview-hint[hidden] { display: none; }
.addphoto .roundedButton_photo, .changepp .roundedButton_photo { width: 100%; margin: 15px 0 0; }
.addphoto .margin_button_addphoto { margin: 0; }
.changepp .undereachother { margin-top: 18px; }
.showFollowers_block, .showFollowing_block { width: min(100%, 500px); }
.showFollowers_block > form, .showFollowing_block > form { position: static; width: auto; height: 0; margin: 0; padding: 0; border: 0; box-shadow: none; }
.showFollowers_block .title_addphoto, .showFollowing_block .title_addphoto { margin-bottom: 16px; }
.showFollowers_block table, .showFollowing_block table { width: 100%; table-layout: fixed; }
.showFollowers_block td, .showFollowing_block td { vertical-align: middle; }
.showFollowers_block .profilepicture_td, .showFollowing_block .profilepicture_td { width: 52px; }
.showFollowers_block .text_showfollower, .showFollowing_block .text_showfollower { width: auto !important; overflow: hidden; }
.showFollowers_block .showsub_showuser_td, .showFollowing_block .showsub_showuser_td { width: 122px !important; }
.showFollowers_block .showsub_showuser, .showFollowing_block .showsub_showuser { float: none; margin: 0 !important; text-align: right; }

.footer { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--line); background: #fff; }
.footer div { max-width: 1160px; margin: 0 auto; padding: 0; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.5; }

@media (max-width: 900px) {
    .topbar { gap: 14px; padding: 10px 20px; }
    .topbar .logolink img { width: 125px; }
    .menu a { padding-inline: 9px; font-size: 13px; }
    .profile-hero { grid-template-columns: 94px minmax(0, 1fr); }
    .profile-hero-avatar { width: 94px; height: 94px; }
    .profile-hero-action { grid-column: 2; }
}

@media (max-width: 680px) {
    .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; padding: 9px 16px 0; }
    .topbar .logolink img { width: 122px; max-height: 38px; }
    .menu { grid-column: 1 / -1; order: 3; width: calc(100vw - 32px); gap: 2px; overflow-x: auto; margin: 0; padding: 2px 0 7px; scrollbar-width: none; }
    .menu::-webkit-scrollbar { display: none; }
    .menu .menu-profile { display: inline-flex; }
    .menu a { min-height: 37px; padding: 7px 11px; font-size: 12px; }
    .logbutton { justify-self: end; }
    .logbutton_span .profile_button { display: none; }
    .logbutton_span a { min-height: 37px; padding: 6px 10px; font-size: 12px; }
    #userspage, #userspage_black { padding: 24px 12px 58px; }
    .feed-intro { padding: 23px 21px; }
    .feed-intro h1, .feed-intro h2 { font-size: 27px !important; }
    .img_display, .create_post, .settings-card, .profile-hero { border-radius: 15px; }
    .post-head { min-height: 68px; padding: 11px 13px; }
    .post-body, .guest-post .post-copy { padding: 15px; }
    .post-avatar, .post-avatar img { width: 41px; height: 41px; }
    .profile-hero { grid-template-columns: 76px minmax(0, 1fr); gap: 14px; padding: 18px; }
    .profile-hero-avatar { width: 76px; height: 76px; border-radius: 17px; }
    .profile-hero-action { grid-column: 1 / -1; }
    .profile-stats { gap: 7px 13px; }
    .settings-card { padding: 0 18px; }
    .showFollowers_block .showsub_showuser_td, .showFollowing_block .showsub_showuser_td { width: 105px !important; }
}

@media (max-width: 440px) {
    .top-topbar { padding-inline: 10px; font-size: 10px; }
    .logbutton_span .logout_button a { padding-inline: 9px; font-size: 11px; }
    .feed-intro h1, .feed-intro h2 { font-size: 25px !important; }
    .post-head { gap: 6px; }
    .post-head .post-author { gap: 8px; }
    .post-badge { display: none; }
    .post-follow .showsub_button, .post-follow .unsubscribe_button { padding: 6px 9px; font-size: 11px; }
    .post-rating { align-items: start; }
    .post-rating .score2 span { display: none; }
    .create_post { padding: 11px 12px; gap: 10px; }
    .create_post .field_photo { padding-left: 11px; }
    .profile-hero { grid-template-columns: 60px minmax(0, 1fr); }
    .profile-hero-avatar { width: 60px; height: 60px; border-radius: 13px; }
    .profile-hero h1 { font-size: 21px; }
    .profile-stats { margin-left: -74px; margin-top: 18px; }
    .settings-avatar { align-items: flex-start; gap: 13px; }
    .settings-avatar-img { width: 62px; height: 62px; }
    .settings-form-row .roundedButton { width: 100%; }
    .edit-row { flex-wrap: wrap; }
    .edit-row input { flex-basis: 100%; }
    .showFollowers_block .showsub_showuser_td, .showFollowing_block .showsub_showuser_td { width: 94px !important; }
    .showFollowers_block .showsub_button, .showFollowing_block .showsub_button, .showFollowers_block .unsubscribe_button, .showFollowing_block .unsubscribe_button { padding: 6px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
