:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-strong: #f0f4f7;
  --line: #dde3ea;
  --text: #17202a;
  --muted: #667485;
  --primary: #235789;
  --primary-strong: #163e63;
  --accent: #2d9c7f;
  --danger: #c94c4c;
  --shadow: 0 18px 45px rgba(22, 35, 51, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #102333;
  color: #ffffff;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #bdd1df;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 34px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dbe8ef;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}

.nav-item.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.toolbar,
.section-head,
.form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 22px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.top-menu {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px;
  box-shadow: var(--shadow);
}

.top-menu .nav-item {
  min-height: 42px;
  background: var(--panel-strong);
  color: var(--text);
  text-align: center;
  font-size: 14px;
}

.top-menu .nav-item.is-active {
  background: var(--primary);
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.icon-button,
.primary,
.secondary,
.danger,
.open-link {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.icon-button {
  width: 44px;
  height: 44px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.primary,
.secondary,
.danger,
.open-link {
  min-height: 42px;
  padding: 0 14px;
}

.primary,
.open-link {
  background: var(--primary);
  color: #ffffff;
}

.primary:hover,
.open-link:hover {
  background: var(--primary-strong);
}

.secondary {
  background: var(--panel-strong);
  color: var(--text);
}

.danger {
  background: #fdeaea;
  color: var(--danger);
}

.toolbar {
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35, 87, 137, 0.12);
}

.search {
  flex: 1 1 420px;
}

.filter {
  flex: 0 0 220px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(360px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.link-list,
.notice-list,
.detail-panel,
.admin-access,
.chat-panel,
.editor,
.admin-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.link-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.notice-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.notice-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 18px;
}

.notice-card h2 {
  margin: 10px 0;
}

.notice-card p {
  margin-bottom: 0;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}

.link-card {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
  text-align: left;
  cursor: pointer;
}

.link-card:hover,
.link-card.is-active {
  border-color: var(--primary);
  background: #f7fbff;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  background: #e7f4f0;
  color: #1f725e;
  padding: 0 9px;
  font-weight: 800;
}

.detail-panel {
  min-height: 360px;
  padding: 22px;
}

.detail-panel p {
  color: var(--muted);
  line-height: 1.6;
}

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.open-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.95fr) minmax(340px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.notice-admin-layout {
  margin-top: 18px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(16, 35, 51, 0.45);
  padding: 20px;
}

.name-modal {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border-radius: 8px;
  background: #ffffff;
  padding: 22px;
  box-shadow: var(--shadow);
}

.name-modal p {
  color: var(--muted);
  line-height: 1.5;
}

.admin-access {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 16px;
}

.admin-access .message {
  grid-column: 1 / -1;
}

.editor,
.admin-list {
  padding: 18px;
}

.editor {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check input {
  width: 18px;
  height: 18px;
}

.message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
}

.table-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.admin-row h3 {
  margin-bottom: 8px;
}

.admin-row p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.is-hidden {
  display: none !important;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1199px) {
  .app-shell {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .sidebar {
    padding: 18px 12px;
  }

  .brand {
    justify-content: center;
  }

  .brand div:last-child {
    font-size: 0;
  }

  .content-grid,
  .admin-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px 14px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .main {
    padding: 18px 14px;
  }

  .topbar {
    align-items: flex-start;
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1 1 0;
  }

  .top-menu {
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .toolbar {
    display: grid;
  }

  .admin-access {
    grid-template-columns: 1fr;
  }

  .filter,
  .search {
    flex-basis: auto;
  }

  .detail-panel {
    min-height: 0;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .admin-row {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: stretch;
  }

  .row-actions button {
    flex: 1 1 120px;
  }
}

.chat-panel {
  display: grid;
  gap: 14px;
  max-width: 920px;
  padding: 18px;
}

.chat-targets {
  display: grid;
  gap: 10px;
}

.user-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.user-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 700;
}

.user-chip.is-active {
  border-color: var(--primary);
  background: #eaf3fb;
  color: var(--primary-strong);
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  background: #eef1f4;
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.is-online {
  background: #e7f4f0;
  color: #1f725e;
}

.chat-messages {
  display: grid;
  gap: 10px;
  min-height: 340px;
  max-height: 52vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
  padding: 12px;
}

.chat-message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.chat-message.is-private {
  border-color: #b8d9cd;
  background: #f3fbf8;
}

.chat-message p {
  margin: 8px 0 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

@media (max-width: 767px) {
  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-messages {
    min-height: 300px;
  }
}
