/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --space-page: 14px;
  --space-stack: 12px;
  --space-block: 10px;
  --space-tight: 8px;
  --radius-card: 14px;
  --radius-control: 10px;
  --border-soft: #e1e6ee;
  --shadow-flat: 0 1px 2px rgba(31, 79, 153, 0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-page);
}

.site-notice-bar {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #cfe2ff;
  border-radius: var(--radius-control);
  background: #eef5ff;
  color: #1f4f99;
  font-size: 14px;
}

.site-notice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-block);
}

.site-notice-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.site-notice-label {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 14px;
}

.site-notice-hint {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #4a6aa1;
}

.site-notice-link {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  color: #0078d7;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.site-notice-link:hover {
  text-decoration: underline;
}

.site-notice-detail {
  width: 100%;
  margin-top: var(--space-tight);
  padding-top: var(--space-tight);
  border-top: 1px solid rgba(31, 79, 153, 0.16);
}

.site-notice-detail-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #244b8f;
  word-break: break-word;
}

.site-notice-detail-link {
  display: inline-flex;
  align-items: center;
  color: #0078d7;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.site-notice-detail-links {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: var(--space-tight);
  margin-top: 8px;
}

.site-notice-detail-link-slot {
  min-width: 0;
}

.site-notice-detail-link-slot-right {
  display: flex;
  justify-content: flex-end;
}

.site-notice-detail-link:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .site-notice-row {
    gap: 8px;
  }

  .site-notice-link {
    min-height: 32px;
  }
}

.dashboard-stack {
  display: grid;
  gap: var(--space-stack);
}

.section-card {
  padding: 14px;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-flat);
}

.accent-card {
  position: relative;
}

.accent-card-warm {
  border-color: #e7ba84;
  background: linear-gradient(180deg, #ffeed8 0%, #ffe3bf 100%);
  box-shadow: 0 2px 10px rgba(176, 105, 22, 0.14);
}

.accent-card-warm .site-notice-panel {
  background: transparent;
}

.section-card .section-title {
  margin-top: 0;
}

.section-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-block);
  margin-bottom: var(--space-block);
}

.section-card-header-start {
  justify-content: flex-start;
}

.section-card-copy {
  min-width: 0;
}

.section-hint-compact {
  margin-bottom: 0;
  line-height: 1.5;
}

.site-notice-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-block);
  margin-bottom: 0;
}

.site-notice-panel-header .section-title {
  margin: 0;
  font-size: 15px;
}

.site-notice-editor {
  margin-top: var(--space-tight);
}

.password-panel,
.site-notice-panel {
  margin: 0;
}

.password-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0;
}

.password-panel-header .section-title {
  margin: 0;
}

.password-form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-tight);
}

/* ── User Info Panel ── */
.user-info-panel {
  margin: 0;
}

.user-greeting-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-block);
  margin-bottom: var(--space-block);
  padding-bottom: var(--space-stack);
  border-bottom: 1px solid #edf2f7;
}

.user-greeting-title {
  flex: 1;
  min-width: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  color: #1a1a2e;
  word-break: break-word;
}

.user-info-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-block);
  margin-bottom: var(--space-tight);
}

.user-info-panel-header .section-title {
  margin: 0;
  font-size: 15px;
}

.user-info-actions {
  display: flex;
  align-items: center;
  gap: var(--space-tight);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quick-phrases-editor {
  display: grid;
  gap: var(--space-tight);
  margin-bottom: var(--space-tight);
}

.user-info-field {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0 2px;
}

.user-info-field-label {
  font-size: 13px;
  color: #999;
}

.user-info-field-value {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.user-info-edit {
  margin-top: var(--space-tight);
}

.user-info-edit-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-control);
  background: #fff;
  color: #333;
  font-family: inherit;
  margin-bottom: var(--space-tight);
}

.user-info-edit-input:focus {
  outline: none;
  border-color: #0078d7;
  box-shadow: 0 0 0 3px rgba(0,120,215,0.12);
}

.user-info-edit-actions {
  display: flex;
  align-items: center;
  gap: var(--space-tight);
}

.field-label-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-tight);
  margin-bottom: 6px;
}

.quick-phrase-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: center;
  justify-self: center;
}

.quick-phrase-btn {
  min-width: 38px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid #d7dfeb;
  border-radius: 8px;
  background: #f7f9fc;
  color: #425466;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.quick-phrase-btn-1 {
  border-color: #9bc2ff;
  background: #edf4ff;
  color: #1f5fbf;
}

.quick-phrase-btn-2 {
  border-color: #9fd8b8;
  background: #eefaf3;
  color: #1d7a46;
}

.quick-phrase-btn-3 {
  border-color: #d7dee7;
  background: #f6f7f9;
  color: #7b8798;
}

.quick-phrase-btn:hover,
.quick-phrase-btn:focus-visible {
  border-color: #8fb4eb;
  background: #edf4ff;
  color: #1f4f99;
}

.quick-phrase-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.quick-phrase-clear-btn {
  flex-shrink: 0;
  border-color: #f0d1a7;
  background: #fff6ea;
  color: #9a5b20;
}

.quick-phrase-clear-btn:hover,
.quick-phrase-clear-btn:focus-visible {
  border-color: #e1b779;
  background: #ffeed8;
  color: #8f4c11;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
  min-height: auto;
}

.btn-compact {
  padding: 7px 16px;
  min-height: 34px;
  font-size: 13px;
  line-height: 1.2;
}

.site-notice-editor textarea {
  min-height: 84px;
}

/* ── Card ── */
.card {
  background: #fff;
  border-radius: var(--radius-card);
  padding: 14px;
  box-shadow: var(--shadow-flat);
}

.mini-program-hint {
  margin-top: 14px;
}

.mini-program-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f7faff;
  border: 1px solid #d9e7fc;
}

.mini-program-card a {
  display: inline-flex;
}

.mini-program-qr {
  width: 120px;
  min-width: 120px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #dde6f3;
}

.mini-program-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.mini-program-copy strong {
  font-size: 15px;
  color: #1a1a2e;
}

.mini-program-copy p {
  margin: 0;
  font-size: 13px;
  color: #5f6f8a;
  line-height: 1.5;
}

.mini-program-link {
  color: #0078d7;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.mini-program-link:hover {
  text-decoration: underline;
}

/* ── App Title ── */
.app-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  color: #1a1a2e;
  margin-bottom: 4px;
}

.app-subtitle {
  font-size: 14px;
  text-align: center;
  color: #888;
  margin-bottom: 24px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 6px;
  margin-top: 16px;
}

.section-title:first-child { margin-top: 0; }

.subsection-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  margin: 0 0 var(--space-tight);
}

.section-hint {
  font-size: 13px;
  color: #999;
  margin-bottom: 12px;
}

/* ── Form ── */
.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 9px 12px;
  font-size: 16px;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-control);
  background: #fff;
  color: #333;
  transition: border-color 0.15s;
  font-family: inherit;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #0078d7;
  box-shadow: 0 0 0 3px rgba(0,120,215,0.12);
}

textarea {
  resize: vertical;
  min-height: 82px;
  line-height: 1.5;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23555' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ── Range slider ── */
input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #d0d5dd;
  border-radius: 3px;
  outline: none;
  margin: 8px 0 4px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #0078d7;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #999;
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  font-family: inherit;
  min-height: 44px;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: #0078d7;
  color: #fff;
}

.btn-primary:hover { background: #106ebe; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
  background: none;
  border: 1px solid #e0a0a0;
  color: #c62828;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}

.btn-danger:hover { background: #fdecea; }

.btn-full { width: 100%; }

.btn-text {
  background: none;
  border: none;
  color: #0078d7;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 5px 8px;
  font-family: inherit;
}

.btn-text:hover,
.btn-text:focus-visible {
  color: #106ebe;
}

/* ── Header ── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px 6px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 2px;
}

.logout-btn {
  color: #106ebe;
  font-size: 13px;
  padding: 0;
  font-weight: 600;
  margin-right: 6px;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.identity-label {
  font-size: 14px;
  font-weight: 600;
  color: #555;
}

.device-overview {
  margin-bottom: 0;
}

.device-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.device-overview-item {
  padding: 8px 8px;
  border-radius: var(--radius-control);
  background: linear-gradient(180deg, #f8fbff 0%, #f2f7ff 100%);
  border: 1px solid #dfebfb;
  text-align: center;
}

.device-overview-item.bound {
  background: linear-gradient(180deg, #f2f7ff 0%, #e8f0ff 100%);
  border-color: #cdddfb;
}

.device-overview-item.online {
  background: linear-gradient(180deg, #f2fbf5 0%, #e9f8ee 100%);
  border-color: #cfead8;
}

.device-overview-item.offline {
  background: linear-gradient(180deg, #f6f7f9 0%, #eceff3 100%);
  border-color: #d7dee7;
}

.device-overview-label {
  display: block;
  font-size: 11px;
  color: #7a8699;
  margin-bottom: 3px;
}

.device-overview-value {
  font-size: 18px;
  line-height: 1;
  color: #1a1a2e;
}

.device-overview-value.bound {
  color: #1f5fbf;
}

.device-overview-value.online {
  color: #13834b;
}

.device-overview-value.offline {
  color: #7b8798;
}

.device-management-panel {
  margin-top: var(--space-stack);
  padding-top: var(--space-stack);
  border-top: 1px solid #edf2f7;
}

.device-management-panel .form-group {
  margin-bottom: 14px;
}

.device-management-panel .status-msg {
  margin-bottom: var(--space-stack);
}

.no-device-hint {
  font-size: 14px;
  text-align: center;
  padding: 14px;
  border-radius: var(--radius-control);
  background: #fff3cd;
  color: #856404;
  margin-top: var(--space-stack);
  margin-bottom: var(--space-stack);
  line-height: 1.8;
}

.no-device-hint a { color: #0078d7; font-weight: 600; }

#content-input::placeholder {
  font-size: 16px;
  line-height: 1.5;
  color: #98a2b3;
}

#content-input {
  height: 90px;
  min-height: 90px;
}

#save-displayname-btn,
#save-password-btn,
#save-site-notice-btn,
#bind-btn {
  padding: 7px 14px;
  min-height: 34px;
  font-size: 13px;
  line-height: 1.2;
}

/* ── Switch link ── */
.switch-link {
  text-align: center;
  font-size: 14px;
  color: #888;
  margin-top: 16px;
}

.switch-link a {
  color: #0078d7;
  text-decoration: none;
  font-weight: 600;
}

/* ── Bind row ── */
.bind-row {
  display: flex;
  gap: var(--space-tight);
}

.bind-row input {
  flex: 1;
}

.bind-row .btn {
  white-space: nowrap;
  padding: 7px 14px;
  font-size: 13px;
  min-height: 34px;
}

/* ── Device List ── */
.device-list { margin-top: 8px; }

.empty-hint {
  text-align: center;
  color: #aaa;
  font-size: 14px;
  padding: 20px 0;
}

.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid #e8e8e8;
  border-radius: var(--radius-control);
  margin-bottom: 8px;
  gap: var(--space-block);
}

.device-info {
  flex: 1;
  min-width: 0;
}

.device-name {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}

.device-meta {
  font-size: 12px;
  color: #999;
}

.device-meta .online { color: #00b400; font-weight: 600; }
.device-meta .offline { color: #aaa; }

/* ── Device Checkboxes (Dashboard) ── */
.device-checkboxes {
  display: flex;
  flex-direction: column;
  gap: var(--space-tight);
}

.device-checkbox-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #e8e8e8;
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: background 0.15s;
}

.device-checkbox-item:hover {
  background: #f5f8ff;
}

.device-checkbox-item input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  accent-color: #0078d7;
  flex-shrink: 0;
  margin-left: auto;
}

.device-cb-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.device-cb-class {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-cb-name {
  font-size: 12px;
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot.online { background: #00b400; }
.dot.offline { background: #ccc; }

/* ── Notification type segmented control ── */
.radio-group {
  display: flex;
  margin-top: 6px;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-control);
  overflow: hidden;
}

.radio-segment {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  background: #fff;
  border-right: 1px solid #d0d5dd;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.radio-segment:last-child { border-right: none; }

.radio-segment input[type="radio"] {
  display: none;
}

.radio-segment-text {
  pointer-events: none;
}

.radio-segment:has(input:checked) {
  background: #0078d7;
  color: #fff;
}

/* ── Duration header: label + checkbox inline ── */
.duration-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

.duration-header label:first-child {
  margin-bottom: 0;
}

.checkbox-label-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
}

.checkbox-label-inline input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #0078d7;
}

/* ── Form row: side-by-side layout ── */
.form-row {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.form-group-flex { flex: 1; min-width: 0; }
.form-group-fixed {
  width: 130px;
  flex-shrink: 0;
  background: #f7f9fc;
  border-radius: var(--radius-control);
  padding: 6px 10px 8px;
  margin-bottom: 0;
}
.form-group-fixed label {
  margin-bottom: 4px;
}

/* ── Permanent display checkbox ── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #555;
  margin-top: 8px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #0078d7;
}

/* ── Device List (improved layout) ── */
.device-class-name {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.device-class-name .online { color: #00b400; font-size: 12px; }
.device-class-name .offline { color: #aaa; font-size: 12px; }

.device-machine {
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
  word-break: break-all;
  font-weight: 400;
}

.device-id-row {
  margin-bottom: 2px;
}

.device-id-value {
  font-size: 11px;
  color: #999;
  font-family: "Consolas", "Courier New", monospace;
  word-break: break-all;
  user-select: all;
}

/* ── Status & Error Messages ── */
.status-msg, .error-msg {
  font-size: 14px;
  text-align: center;
  padding: 9px 10px;
  border-radius: var(--radius-control);
  margin-bottom: var(--space-stack);
}

.status-msg.success {
  color: #007a33;
  background: #e6f7ee;
}

.status-msg.error, .error-msg {
  color: #c62828;
  background: #fdecea;
}

@media (max-width: 480px) {
  .container {
    padding: 12px;
  }

  .section-card {
    padding: 14px;
  }

  .section-card-header,
  .site-notice-panel-header,
  .user-greeting-row,
  .user-info-panel-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .user-greeting-title {
    font-size: 18px;
  }

  .user-info-actions {
    justify-content: flex-start;
  }

  .field-label-row {
    align-items: center;
    grid-template-columns: auto 1fr auto;
    gap: 6px;
  }

  .quick-phrase-buttons {
    gap: 4px;
    justify-content: center;
    justify-self: center;
  }

  .quick-phrase-clear-btn {
    justify-self: end;
  }

  .quick-phrase-btn {
    min-width: 34px;
    min-height: 28px;
    padding: 0 6px;
    font-size: 11px;
  }

  .device-overview-grid {
    gap: 8px;
  }

  .device-overview-item {
    padding: 8px 7px;
  }

  .device-overview-value {
    font-size: 17px;
  }

  .bind-row {
    flex-direction: column;
  }

  .bind-row .btn {
    width: 100%;
  }

  .device-item {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-danger {
    width: 100%;
  }
}
