:root {
  color-scheme: light;
  --accent: #c45b2b;
  --accent-deep: #a04017;
  --bg: #fffaf5;
  --bg-gradient-start: #fff0e2;
  --bg-gradient-end: #ffe0d0;
  --text: #2a1b0f;
  --muted: #8b6f5a;
  --border: #eadfd6;
  --card-bg: rgba(255, 255, 255, 0.95);
  --page-padding: clamp(1rem, 4vw, 4rem);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", Arial, sans-serif;
  background: radial-gradient(circle at top, var(--bg-gradient-start), var(--bg-gradient-end));
  color: var(--text);
  line-height: 1.7;
}

.hero {
  background: linear-gradient(120deg, #f3b17a, #fbe0c1);
  padding: 2rem var(--page-padding);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  position: relative;
  overflow: hidden;
}

.hero__content h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 3vw, 2.5rem);
}

.hero__image {
  margin: 0;
  flex: 0 0 200px;
  max-width: 240px;
  border-radius: 1.25rem;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.hero__image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.hero nav {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.hero nav a {
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
}

@media (max-width: 640px) {
  .hero {
    flex-direction: column;
    text-align: center;
  }

  .hero__image {
    flex: 0 0 auto;
    width: min(320px, 90%);
  }

  .hero nav {
    justify-content: center;
  }
}

main {
  padding: 2rem var(--page-padding);
  min-height: 70vh;
  overflow: hidden;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--card-bg);
  border-radius: 1.25rem;
  padding: 1.75rem;
  box-shadow: 0 25px 50px rgba(196, 91, 43, 0.08);
}

.card__meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.6rem 1.5rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: white;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(196, 91, 43, 0.25);
}

.link {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
}

.flash-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
}

.flash--success { background: #e3f8e5; }
.flash--danger { background: #fde2dd; }
.flash--info { background: #dfefff; }

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-note {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  gap: 0.3rem;
}

.form-grid input,
.form-grid textarea {
  padding: 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  font: inherit;
}

.full-width {
  grid-column: 1 / -1;
}

.full-bleed {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  border-radius: 0;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

table th,
table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.admin-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stream-create-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}

.stream-create-form input[type="text"],
.stream-create-form input[type="url"] {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  font: inherit;
}

.inline-form {
  display: inline;
}

.inline-form button {
  background: none;
  border: none;
  color: #b00020;
  cursor: pointer;
}

.text-right {
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: #ddd;
  font-size: 0.85rem;
}

.tag--primary {
  background: var(--accent);
  color: #fff;
}

.map-container,
#map,
#map.leaflet-container {
  width: 100%;
  min-height: 380px;
  margin-top: 1.5rem;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid var(--border);
}

.marker-number {
  background: transparent;
  border: none;
}

.marker-number .marker-label {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.chat-panel {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.livestream-feature {
  margin-bottom: 2rem;
}

.livestream-feature__header {
  margin-bottom: 0.75rem;
}

.livestream-feature__hint {
  margin: 0;
  color: var(--muted);
}

.livestream-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.livestream-tab {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}

.livestream-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.livestream-feature__embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 1rem;
  overflow: hidden;
  background: #000;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.livestream-feature__embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.livestream-feature__link {
  margin-top: 0.5rem;
  text-align: right;
}

.livestream-feature__link a {
  color: var(--accent);
  font-weight: 600;
}

.chat-panel__header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chat-panel__hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-messages {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 248, 242, 0.8);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.08);
}

.chat-message:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.chat-message__time {
  font-size: 0.85rem;
  color: var(--muted);
  flex: 0 0 3rem;
}

.chat-message__content {
  margin: 0;
  flex: 1;
}

.chat-empty {
  margin: 0;
  color: var(--muted);
}

.chat-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.chat-form input[type="text"] {
  flex: 1 1 220px;
  padding: 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font: inherit;
}

.chat-form .button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.block-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}

.block-form input[type="text"] {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  font: inherit;
}

.livestream-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.livestream-item {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
}

.livestream-item__form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.livestream-item__form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 600;
}

.livestream-item__form input[type="text"],
.livestream-item__form input[type="url"] {
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  font: inherit;
}

.livestream-item__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.livestream-item__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

@media (min-width: 640px) {
  .chat-panel__header {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
  }
}
