/* === 20260922 editor-actions: real buttons for word-edit UI === */
/* Brand: #76b900 · touch ≥44px · mobile/focus-view first */

.editor-tools {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px !important;
  align-items: stretch !important;
  width: 100%;
}

.editor-tools button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 12px;
  margin: 0;
  border: 1.5px solid #76b900 !important;
  border-radius: 10px;
  background: #f4faf0 !important;
  color: #111 !important;
  font-size: 15px !important;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none !important;
  white-space: normal;
  word-break: break-word;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}

.editor-tools button:hover:not(:disabled) {
  background: #e8f5d6 !important;
}

.editor-tools button:active:not(:disabled) {
  background: #dcefc0 !important;
}

.editor-tools button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.editor-tools small {
  grid-column: 1 / -1;
  color: #00000099;
  font-size: 13px !important;
  line-height: 1.45;
  margin-top: 2px;
}

/* Desktop list: wrap as horizontal button row if wide enough */
@media (min-width: 641px) {
  .editor-tools {
    display: flex !important;
    flex-wrap: wrap;
    gap: 10px !important;
  }
  .editor-tools button {
    flex: 0 1 auto;
    min-width: 120px;
    padding: 10px 16px;
  }
  .editor-tools small {
    flex: 1 1 100%;
  }
}

/* memory-actions: Save / Cancel / 修改 as real buttons */
.memory-actions {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start !important;
  gap: 10px !important;
  min-height: 44px;
  width: 100%;
}

.memory-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 88px;
  padding: 10px 18px !important;
  margin: 0;
  border-radius: 10px;
  font-size: 16px !important;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none !important;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}

/* Editing: Save primary, Cancel outline */
.memory-actions:has(button:nth-of-type(2)) button:first-of-type {
  flex: 1 1 0;
  background: #76b900 !important;
  border: 1.5px solid #76b900 !important;
  color: #000 !important;
}

.memory-actions:has(button:nth-of-type(2)) button:nth-of-type(2) {
  flex: 1 1 0;
  background: #fff !important;
  border: 1.5px solid #00000040 !important;
  color: #111 !important;
}

/* Idle: 修改 as soft secondary */
.memory-actions:not(:has(button:nth-of-type(2))) button:first-of-type {
  background: #f4faf0 !important;
  border: 1.5px solid #76b900 !important;
  color: #111 !important;
}

.memory-actions button:hover:not(:disabled) {
  filter: brightness(0.97);
}

.memory-actions button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.memory-actions span[role="status"],
.memory-actions > span {
  flex: 1 1 auto;
  min-width: 0;
  color: #00000099;
  font-size: 13px !important;
  text-align: left;
}

/* Word editor comfort */
.word-editor {
  gap: 14px !important;
  padding: 14px !important;
  border-radius: 12px;
}

.word-editor label {
  gap: 8px !important;
  font-size: 14px;
  font-weight: 600;
}

.word-editor input,
.word-editor textarea,
.word-editor [data-slot="input"],
.word-editor [data-slot="textarea"] {
  font-size: 16px !important;
  min-height: 44px;
  border-radius: 8px;
}

.word-editor textarea {
  min-height: 96px !important;
}

/* Focus card: single column on narrow + focus-view */
.focus-view .word-editor {
  display: flex !important;
  flex-direction: column !important;
  gap: 14px !important;
  padding: 16px !important;
  margin-top: 4px;
}

.focus-view .word-editor > * {
  width: 100%;
  max-width: 100%;
}

.focus-view .editor-tools {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px !important;
}

.focus-view .memory-actions:has(button:nth-of-type(2)) {
  position: sticky;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  z-index: 4;
  margin-top: 8px;
  padding: 10px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #ffffff00 0%, #fffffff5 28%, #fff 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.focus-view .memory-cell textarea,
.focus-view .word-editor input,
.focus-view .word-editor textarea {
  font-size: 16px !important;
}

@media (max-width: 640px) {
  .word-editor {
    grid-template-columns: minmax(0, 1fr) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .word-editor > * {
    grid-column: 1 !important;
    width: 100%;
  }

  .editor-tools {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Shorten long first tool label on very small phones via visual clamp — keep readable */
  .editor-tools button {
    font-size: 14px !important;
    padding: 10px 8px;
  }

  .memory-actions:has(button:nth-of-type(2)) {
    position: sticky;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    z-index: 4;
    padding: 10px 0 calc(6px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, #ffffff00 0%, #fffffff5 28%, #fff 100%);
  }

  .memory-actions:has(button:nth-of-type(2)) button {
    flex: 1 1 calc(50% - 5px);
  }

  /* Leave room above listen-bar when editor open */
  .workspace {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }
}

/* Do not fight listen-bar / spelling controls */
.listen-bar {
  z-index: 5;
}
.listen-bar button {
  /* preserve existing */
}
