:root {
  color-scheme: light;
  --ink: #241a38;
  --ink-strong: #1f1433;
  --muted: #6b5687;
  --accent: #6b4f8b;
  --accent-light: rgba(123, 98, 165, 0.14);
  --surface: rgba(255, 255, 255, 0.68);
  --panel: rgba(255, 255, 255, 0.48);
  --line: rgba(255, 255, 255, 0.72);
  --danger: #a13f57;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 20px;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 12%, rgba(255, 255, 255, 0.95), transparent 28%),
    linear-gradient(160deg, #f0edf7 0%, #e6e1ef 100%);
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.card {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 32px 36px 40px;
  border: 1px solid var(--line);
  border-radius: 56px;
  background: var(--surface);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
}

.profile-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 24px 30px;
  margin-bottom: 28px;
}

.avatar-wrapper {
  position: relative;
  width: 110px;
  height: 110px;
  flex: 0 0 auto;
  overflow: hidden;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: #d4c8e6;
  box-shadow: 0 10px 24px -6px rgba(80, 60, 110, 0.2);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.avatar-wrapper:hover { transform: scale(1.025); box-shadow: 0 14px 30px -8px rgba(70, 50, 100, 0.32); }
.avatar-wrapper:focus-visible { outline: 4px solid rgba(107, 79, 139, 0.22); }
.avatar-wrapper img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder { display: grid; width: 100%; height: 100%; place-items: center; color: #3f2d5e; font-size: 44px; font-weight: 550; background: #b7a9d4; }

.name-title { flex: 1; }
.name-title h1 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--ink-strong); font-size: clamp(2rem, 5vw, 2.5rem); line-height: 1.1; }
.name-title h1 i { color: #7b62a5; font-size: 1.35rem; opacity: 0.4; }
.school-tag { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.school-tag span { display: inline-flex; align-items: center; gap: 8px; padding: 6px 18px; border: 1px solid var(--line); border-radius: 40px; color: #352554; background: rgba(106, 78, 148, 0.1); font-size: 0.85rem; font-weight: 500; }
.school-tag i { color: var(--accent); }
.auth-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.auth-button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 30px; background: rgba(255, 255, 255, 0.48); color: #60497d; font-size: 0.76rem; cursor: pointer; }
.auth-button:hover { background: rgba(255, 255, 255, 0.78); }
.admin-only { display: none !important; }
body.is-admin .admin-only { display: inline-flex !important; }
body.is-admin .delete-button.admin-only { display: grid !important; }
body.is-admin #loginButton { display: none; }
body:not(.is-admin) .avatar-wrapper { cursor: default; }
body:not(.is-admin) .image-picker { cursor: default; }
body:not(.is-admin) .image-picker:disabled { color: inherit; opacity: 1; }
body:not(.is-admin) .avatar-wrapper:hover { transform: none; box-shadow: 0 10px 24px -6px rgba(80, 60, 110, 0.2); }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 24px 0 30px; }
.info-panel { padding: 18px 22px; border: 1px solid var(--line); border-radius: 32px; background: var(--panel); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.02); }
.info-panel h2, .section-header h2, .guestbook-header h2 { margin: 0; color: #5b4679; font-size: 0.76rem; font-weight: 650; letter-spacing: 1.2px; text-transform: uppercase; }
.info-panel h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.bio-content { min-height: 54px; padding: 4px 0; border-radius: 12px; outline: none; line-height: 1.65; white-space: pre-wrap; }
.bio-content:focus { margin: 0 -10px; padding: 4px 10px; background: rgba(255, 255, 255, 0.38); box-shadow: 0 0 0 3px rgba(106, 78, 148, 0.12); }
.click-hint { margin: 4px 0 0; color: #8f7aa8; font-size: 0.65rem; opacity: 0.7; }
.contact-item { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid rgba(106, 78, 148, 0.08); }
.contact-item:last-child { border-bottom: 0; }
.contact-item i { width: 22px; color: var(--accent); }
.contact-item a { color: var(--ink); text-decoration: none; word-break: break-all; }
.contact-item a:hover { color: #4b2d75; text-decoration: underline; }

.content-section { margin: 32px 0 30px; }
.section-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-header h2 { display: flex; align-items: center; gap: 10px; }
.pill-button { display: inline-flex; align-items: center; gap: 8px; padding: 8px 18px; border: 1px solid var(--line); border-radius: 40px; background: var(--accent-light); color: #3d2a5e; font-size: 0.82rem; font-weight: 550; cursor: pointer; transition: transform 0.18s ease, background 0.18s ease; }
.pill-button:hover { transform: translateY(-1px); background: rgba(123, 98, 165, 0.24); }
.pill-button:disabled { cursor: wait; opacity: 0.55; }

.works-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 24px; }
.work-card, .blog-card { position: relative; overflow: hidden; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.56); box-shadow: 0 8px 20px -10px rgba(60, 40, 80, 0.16); transition: transform 0.22s ease, box-shadow 0.22s ease; }
.work-card { display: flex; min-width: 0; flex-direction: column; border-radius: 32px; }
.work-card:hover, .blog-card:hover { transform: translateY(-4px); box-shadow: 0 16px 32px -12px rgba(60, 40, 80, 0.2); }
.image-picker { position: relative; display: grid; width: 100%; height: 160px; overflow: hidden; place-items: center; border: 0; background: #d9cee8; cursor: pointer; }
.image-picker img { width: 100%; height: 100%; object-fit: cover; }
.image-placeholder { display: flex; flex-direction: column; align-items: center; gap: 7px; color: #8f7aa8; font-size: 0.76rem; opacity: 0.72; pointer-events: none; }
.image-placeholder i { font-size: 2.4rem; opacity: 0.55; }
.work-info { flex: 1; padding: 14px 16px 18px; }
.editable { border-radius: 8px; outline: none; }
.editable:focus { margin-left: -7px; margin-right: -7px; padding-left: 7px; padding-right: 7px; background: rgba(255, 255, 255, 0.6); box-shadow: 0 0 0 2px rgba(106, 78, 148, 0.12); }
.work-title { margin-bottom: 3px; color: var(--ink-strong); font-size: 1rem; font-weight: 650; }
.work-desc { color: #675a76; font-size: 0.8rem; line-height: 1.45; }
.delete-button { position: absolute; z-index: 2; top: 10px; right: 10px; display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid rgba(255, 255, 255, 0.72); border-radius: 50%; background: rgba(255, 255, 255, 0.84); color: var(--danger); cursor: pointer; opacity: 0; transition: opacity 0.18s ease, transform 0.18s ease; }
.work-card:hover .delete-button, .blog-card:hover .delete-button, .delete-button:focus-visible { opacity: 1; }
.delete-button:hover { transform: scale(1.08); }

.blog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search-box { display: flex; align-items: center; gap: 8px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 30px; background: rgba(255, 255, 255, 0.55); color: #806d96; }
.search-box input { width: 140px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 20px; }
.blog-card { display: grid; grid-template-columns: 112px 1fr; min-height: 138px; border-radius: 26px; }
.blog-card .image-picker { height: 100%; min-height: 138px; }
.blog-card .image-placeholder { padding: 8px; text-align: center; }
.blog-content { min-width: 0; padding: 15px 18px 16px; }
.blog-title { padding-right: 18px; color: var(--ink-strong); font-size: 1rem; font-weight: 650; }
.blog-meta { display: flex; align-items: center; gap: 7px; margin: 8px 0; color: #8f7aa8; font-size: 0.72rem; }
.blog-date { width: 122px; padding: 0; border: 0; outline: 0; background: transparent; color: inherit; }
.blog-summary { color: #675a76; font-size: 0.8rem; line-height: 1.5; }

.guestbook-section { margin-top: 34px; padding: 22px; border: 1px solid var(--line); border-radius: 32px; background: rgba(255, 255, 255, 0.4); }
.guestbook-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.guestbook-header > i { color: #7b62a5; opacity: 0.7; }
.guestbook-form { display: flex; align-items: stretch; gap: 10px; }
.guestbook-form input, .guestbook-form textarea { min-width: 0; padding: 11px 14px; border: 1px solid rgba(106, 78, 148, 0.14); border-radius: 18px; outline: 0; background: rgba(255, 255, 255, 0.64); color: var(--ink); resize: vertical; }
.guestbook-form input { flex: 0 1 170px; }
.guestbook-form textarea { flex: 1 1 300px; min-height: 44px; }
.guestbook-form input:focus, .guestbook-form textarea:focus { border-color: rgba(106, 78, 148, 0.42); box-shadow: 0 0 0 3px rgba(106, 78, 148, 0.1); }
.guestbook-form button { flex: 0 0 auto; padding: 10px 20px; border: 0; border-radius: 18px; background: #6d538f; color: #fff; cursor: pointer; }
.guestbook-form button:disabled { cursor: wait; opacity: 0.6; }
.comments-list { display: grid; gap: 10px; margin-top: 16px; }
.comment-item { padding: 12px 15px; border-radius: 18px; background: rgba(255, 255, 255, 0.52); }
.comment-name { color: #4e386c; font-size: 0.82rem; font-weight: 650; }
.comment-name time { margin-left: 6px; color: #9586a4; font-size: 0.66rem; font-weight: 400; }
.comment-text { margin-top: 5px; color: #4d4358; font-size: 0.86rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.empty-state { grid-column: 1 / -1; padding: 28px; border: 1px dashed rgba(106, 78, 148, 0.18); border-radius: 24px; color: #8f7aa8; text-align: center; }
.empty-state i { margin-right: 7px; }

.footer-note { margin: 26px 0 0; color: #8d7d9d; font-size: 0.72rem; text-align: center; }
.footer-note.is-error { color: #a13f57; }
.toast { position: fixed; z-index: 99; bottom: 30px; left: 50%; max-width: min(90%, 600px); padding: 13px 24px; border-radius: 60px; background: rgba(30, 20, 50, 0.9); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25); color: white; font-size: 0.88rem; text-align: center; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity 0.25s ease, transform 0.25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.login-dialog { width: min(420px, calc(100% - 28px)); padding: 0; border: 1px solid rgba(255, 255, 255, 0.82); border-radius: 30px; background: rgba(248, 246, 252, 0.96); box-shadow: 0 28px 80px rgba(31, 20, 51, 0.35); color: var(--ink); }
.login-dialog::backdrop { background: rgba(32, 22, 46, 0.35); backdrop-filter: blur(5px); }
.login-form { position: relative; display: grid; gap: 10px; padding: 30px; }
.login-form h2 { margin: 2px 0 0; color: var(--ink-strong); text-align: center; }
.login-form p { margin: 0 0 8px; color: #746783; font-size: 0.82rem; line-height: 1.5; text-align: center; }
.login-form label { margin-top: 3px; color: #554568; font-size: 0.76rem; font-weight: 650; }
.login-form input { width: 100%; padding: 11px 13px; border: 1px solid rgba(106, 78, 148, 0.2); border-radius: 14px; outline: 0; background: #fff; color: var(--ink); }
.login-form input:focus { border-color: rgba(106, 78, 148, 0.5); box-shadow: 0 0 0 3px rgba(106, 78, 148, 0.1); }
.login-icon { display: grid; width: 52px; height: 52px; margin: 0 auto; place-items: center; border-radius: 18px; background: rgba(107, 79, 139, 0.12); color: var(--accent); font-size: 1.3rem; }
.dialog-close { position: absolute; top: 15px; right: 15px; display: grid; width: 30px; height: 30px; place-items: center; border: 0; border-radius: 50%; background: rgba(107, 79, 139, 0.08); color: #705f82; cursor: pointer; }
.login-submit { display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; padding: 11px 18px; border: 0; border-radius: 15px; background: #6d538f; color: #fff; cursor: pointer; }
.login-submit:disabled { cursor: wait; opacity: 0.6; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 680px) {
  body { padding: 10px; }
  .card { padding: 26px 18px 30px; border-radius: 34px; }
  .profile-header { flex-direction: column; text-align: center; }
  .name-title h1, .school-tag { justify-content: center; }
  .auth-actions { justify-content: center; }
  .info-grid { grid-template-columns: 1fr; }
  .guestbook-form { flex-wrap: wrap; }
  .guestbook-form input, .guestbook-form textarea { flex-basis: 100%; }
  .guestbook-form button { width: 100%; }
}

@media (max-width: 430px) {
  .works-grid, .blog-grid { grid-template-columns: 1fr; }
  .blog-card { grid-template-columns: 94px 1fr; }
  .blog-actions, .search-box { width: 100%; }
  .search-box input { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
